Hard Links vs Symbolic Links in Linux

Linux gives you two ways to make a file accessible under more than one name: hard links and symbolic links. They look similar in a directory listing, and both are created with the ln command, but they work in fundamentally different ways. Choosing the wrong one leads to surprises, such as a link that breaks when you move a file, or a “copy” that still takes up space after you delete the original. Understanding what each link actually points to makes the choice obvious.
This guide explains how hard links and symbolic links differ, what an inode is, when each type breaks, and which one to reach for in common situations.
What an Inode Is
To see the difference, you first need to know how Linux stores a file. Every file’s data is tracked by an inode, a structure that holds the metadata (permissions, owner, size, timestamps) and the location of the data on disk. The file name you see is not the file itself; it is a directory entry that points to an inode. The inode, in turn, points to the data.
This separation is the whole story. A hard link is another directory entry pointing at the same inode. A symbolic link is a small file of its own that contains a path to another name.
You can see inode numbers with ls -i:
ls -i document.txt1572881 document.txtThe number on the left is the inode. Two names that share an inode number are the same file.
Hard Links
A hard link is an additional name for an existing inode. Both names are equal; neither is the “original.” Create one by passing the existing file and the new name to ln with no options:
ln document.txt backup.txtNow list both with ls -li to see what happened:
ls -li document.txt backup.txt1572881 -rw-r--r-- 2 dejan dejan 102 Jan 1 09:00 backup.txt
1572881 -rw-r--r-- 2 dejan dejan 102 Jan 1 09:00 document.txtBoth names share inode 1572881, so they are the same file viewed through two directory entries. The number 2 after the permissions is the link count: the inode now has two names. Editing through either name changes the same data, because there is only one set of data.
Because both names are equal, deleting one does not remove the file. The data survives until the link count reaches zero:
rm document.txtAfter this, backup.txt still contains everything, and the link count drops to 1. The file is only freed when its last name is removed.
Hard links have two firm limits that come from how inodes work:
- They cannot cross filesystems. An inode number is only meaningful within one filesystem, so a hard link and its target must live on the same filesystem.
- They cannot link directories. Allowing this would let you create loops in the directory tree, so the kernel forbids it for ordinary users.
Symbolic Links
A symbolic link, also called a symlink or soft link, is a separate small file that holds the path to another file or directory. It has its own inode, and its contents are simply the target path. Create one by adding the -s option to ln:
ln -s report.txt shortcut.txtList it with ls -li:
ls -li report.txt shortcut.txt1572895 -rw-r--r-- 1 dejan dejan 102 Jan 1 09:00 report.txt
1572902 lrwxrwxrwx 1 dejan dejan 10 Jan 1 09:05 shortcut.txt -> report.txtThe symlink has a different inode (1572902), the type field starts with l for link, and the listing shows where it points with the -> arrow. When you open shortcut.txt, the kernel follows the stored path to report.txt and works with that file.
Because a symlink only stores a path, it is far more flexible than a hard link:
- It can point across filesystems, since it holds a path rather than an inode number.
- It can point to a directory, which is how most “shortcut to a folder” setups work.
The trade-off is that a symlink depends on its target existing. If you remove or rename report.txt, the symlink still points to the old path and becomes a dangling link:
rm report.txt
cat shortcut.txtcat: shortcut.txt: No such file or directoryThe error comes from the missing target, not from the link being removed. You can still see the dangling symlink with ls -l:
ls -l shortcut.txtlrwxrwxrwx 1 dejan dejan 10 Jan 1 09:05 shortcut.txt -> report.txtThe link is still there, but it points to nothing. Moving the target breaks a symlink in the same way, while a hard link is unaffected because it does not depend on a path.
Key Differences
The table below summarizes how the two types compare:
| Property | Hard link | Symbolic link |
|---|---|---|
| Points to | The same inode (the data) | A path to another name |
| Own inode | No, shares the target’s | Yes, separate inode |
| Cross filesystems | No | Yes |
| Link to a directory | No | Yes |
| Survives deleting the target | Yes, data persists | No, becomes a dangling link |
| Survives moving the target | Yes | No, the stored path breaks |
| Create with | ln target name | ln -s target name |
Which One to Use
Reach for a symbolic link in most everyday cases. Linking to a directory, pointing to a file on another disk, or creating a shortcut whose target may be replaced later all require a symlink, and the visible -> target makes the relationship easy to understand. The current versions of configuration files and the entries under /etc/alternatives are managed with symlinks for exactly these reasons.
Choose a hard link when you want two names that are truly the same file on one filesystem and you want the data to survive even if one name is removed. Backup and snapshot tools use hard links to make multiple directory trees share unchanged files without storing the data twice, which is efficient because the bytes exist only once.
FAQ
What is the main difference between a hard link and a symbolic link?
A hard link is another name for the same inode and shares the file’s data directly. A symbolic link is a separate file that stores a path to another name. Deleting the target keeps a hard link working but breaks a symbolic link.
Why can I not create a hard link across two disks?
A hard link points to an inode number, which is only unique within a single filesystem. A target on another filesystem has no meaningful inode in the first filesystem, so the kernel rejects the hard link. Use a symbolic link instead.
How do I tell whether a file is a symlink?
Run ls -l. A symbolic link’s permission string starts with l and the listing shows the target after a -> arrow. A hard link looks like an ordinary file, but ls -li reveals it shares an inode number with its other names.
What happens to a hard link when I delete the original?
Nothing is lost. The two names are equal, so removing one only decreases the link count. The data is freed only when the last name pointing to the inode is removed.
Conclusion
The difference comes down to what each link points to: a hard link is another name for the same inode and its data, while a symbolic link is a pointer to a path that can break. Use symlinks for directories, cross-disk references, and shortcuts, and use hard links when you want identical, persistent names for one file on a single filesystem. For the commands themselves, see our guide on creating symbolic links with ln and on removing symbolic links .
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page