Hard Links vs Soft Links
Linux has two types of links — hard links and symbolic (soft) links. They both look similar on the surface, but internally they work completely differently. Understanding them requires understanding inodes, which are how Linux actually tracks files.
The Key Insight: Files Are Not Their Names
Hard Links — Another Name for the Same Inode
A hard link is just another directory entry pointing to the same inode. The file's actual data exists once on disk; two filenames point to it.
rm hello.txt leaves hello-hardlink.txt fully intact.
Hard link limitations:
- Cannot link across different filesystems (inodes are filesystem-specific)
- Cannot link to directories (would create filesystem loops)
Symbolic Links — A File Containing a Path
A symbolic link (symlink) is a special file that contains a text path to another file or directory. When you access a symlink, the kernel follows the path stored in it.
Symlink advantages:
- Can cross filesystem boundaries
- Can link to directories
- Can point to relative or absolute paths
When to Use Which
| Hard Link | Symbolic Link | |
|---|---|---|
| Points to | Inode directly | File path (string) |
| Cross-filesystem | No | Yes |
| Link to directories | No | Yes |
| Breaks if original deleted | No (survives) | Yes (dangling) |
| Common use case | Backup systems, package managers | Versioning (python → python3.11), /etc/alternatives |
Frequently Asked Questions
What will I learn here?
This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.
How should I use this page?
Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.
What should I read next?
Use the navigation below to continue to the next lesson or explore related topics.