This is another topic in Linux that usually got me thinking in circles. To Create and change hard and symbolic links in Linux is something I don’t usually do on a daily basis as a Sysadmin. Maybe you don’t either. I decided to brew a great cup of Caturra variety coffee at home before taking on this one.
Create links in Linux
Hard links
- Point directly to the same inode (data on disk).
- Both files are equal; deleting one does not remove the other unless all links are deleted.
- Cannot cross filesystems or link directories.
# Create a file
echo "Take this" > /etc/takeapp.conf
# Create a hard link
ln /etc/takeapp.conf /etc/takeapp_hardlink.conf
# Verify (same inode)
ls -li /etc/takeapp*
# inode_number takeapp.conf
# inode_number takeapp_hardlink.confBoth files now share the same inode. Changing either modifies the same data.
Symbolic (soft) links
- Work like Windows shortcuts.
- Store a path that points to the target.
- Can cross filesystems.
- Can point to directories.
# Create a symlink
ln -s /etc/myapp.conf /etc/myapp_symlink.conf
# Verify
ls -l /etc/myapp*
# myapp_symlink.conf -> /etc/myapp.confIdentify hard vs. soft links
- Hard link: same inode number.
- Soft link: shows
->inls -l.
ls -liFor example you will see the below output:
12345 -rw-r--r-- 2 root root 20 Jan 1 myapp.conf
12345 -rw-r--r-- 2 root root 20 Jan 1 myapp_hardlink.conf
12346 lrwxrwxrwx 1 root root 12 Jan 1 myapp_symlink.conf -> myapp.confCopying vs. linking
Copying makes a new file with its own inode:
cp /etc/myapp.conf /etc/myapp_copy.confEditing myapp_copy.conf does NOT affect the original.
Use links when you want changes reflected across all references.
Use copy when you want independence.
Use links for sysadmin tasks
Example 1: Easier paths you can create a symlink(soft link)
# Symlink long paths for convenience
ln -s /var/log/nginx/access.log ~/nginx_access.log
tail -f ~/nginx_access.logUseful for switching config versions. For example:
# Keep multiple configs
/etc/myapp.conf.v1
/etc/myapp.conf.v2
# Use symlink to choose active one
ln -sf /etc/myapp.conf.v2 /etc/myapp.conf
systemctl restart myappAlso, for shared binaries you can do this:
# Point to a single tool version
ln -s /opt/python3.11/bin/python3 /usr/bin/python3Key difference recap:
- Hard links = same inode (data), no arrows.
- Symlinks = pointer to path, shows
->. - Copies = independent files.
Copy vs. Hard Link vs. Soft Link comparison table
| Feature | Copy | Hard Link | Soft (Symbolic) Link |
|---|---|---|---|
| Definition | Independent duplicate of file | Another filename pointing to the same inode (data on disk) | A shortcut that stores the path to the target file |
| Inode | New inode | Same inode as original | Different inode, points to original path |
| File contents | Independent | Shared (changes affect all links) | Shared (but breaks if target is deleted/moved) |
| Cross-filesystem? | Yes | ❌ No (must be same filesystem) | ✅ Yes |
| Works on directories? | ✅ Yes | ❌ No (only files) | ✅ Yes |
| If original is deleted | Copy remains intact | Other links still access data until all are deleted | Link becomes broken (dangling symlink) |
| Performance | Uses more disk space | Efficient (no duplicate data) | Small overhead (stores path only) |
| Use cases | Backup, independence | Duplicate filename for same file (e.g., multiple valid paths) | Shortcuts, convenience, version switching |
Creating hard and symbolic links in Linux can be tricky to understand. Hopefully this tutorial helps somebody out there. Below are some of my T-Shirt and coffee mugs designs. If you like them you can place an order today. Thanks!
ITPro Helper shop
apt install Coffee Mug
$19.95IT Handyman Coffee Mug White
$16.00Yoda Unisex Hoodie
$39.00Code with Coffee Short-Sleeve Unisex T-Shirt
Price range: $24.00 through $28.00





