Understanding UNIX / Linux symbolic (soft) and hard links
Inodes are associated with precisely one directory entry at a time. However, with hard links it is possible to associate multiple directory entries with a single inode. To create a hard link use ln command:
# ln /root/file1 /root/file2
# ls -l
Above commands create a link to file1.
Hard link vs. Soft link in Linux or UNIX
- Hard links cannot links directories
- Cannot cross file system boundaries
Soft or symbolic links are just like hard links. It allows to associate multiple filenames with a single file. However, symbolic links allows:
- To create links between directories
- Can cross file system boundaries
These links behave differently when the source of the link is moved or removed.
- Symbolic links are not updated
- Hard links always refer to the source, even if moved or removed
How do I create symbolic link?
You can create symbolic link with ln command:
$ ln -s /path/to/ file1.txt file2.txt
$ ls -l
Above command will create a symbolic link to file1.txt. Read man page of ln for more information.
Continue reading rest of the Understanding Linux file system series (this is part VI):
- Part I - Understanding Linux superblock
- Part II - Understanding Linux superblock
- Part III - An example of Surviving a Linux Filesystem Failures
- Part IV - Understanding filesystem Inodes
- Part V - Understanding filesystem directories
- Part VI - Understanding UNIX/Linux symbolic (soft) and hard links
- Part VII - Why isn't it possible to create hard links across file system boundaries?
You may also be interested in other helpful articles:
- Comparison Linux vs UNIX file systems
- Why isn’t it possible to create hard links across file system boundaries?
- Understanding UNIX / Linux filesystem directories
- Understanding UNIX / Linux filesystem Superblock
- Understanding UNIX / Linux filesystem Inodes
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: hard_links, inode, linux_filesystem, ln_command, soft_links, unix_filesystem



Thank u Vivek Gite Sir,
for posting very nice article about linux filesystem…