Symlinks and Hardlinks
Files are arranged in directories and each file can be reached through a series of directories and subdirectories from the root – correct? Yes … BUT … there are sometimes that the same file can be reached through several names, and on Unix and Linux systems this is known as a “link”.
In this article, We are going to understand some important points and working techniques of Symlinks and Hardlinks.
There are two ways a link can be set up.
1. Symlink [Symbolic Link]:
A symlink is also called as Soft link. Symlink is a file which contains a reference to another file or directory in the form of absolute or relative path.
In simple word, you can create a shortcut of file or directory to the other path using symlink feature.
Important points about the Symlink:
$ Links have different inode numbers.
54665305 -rw-r--r-- 1 prashant prashant 0 Nov 15 14:56 testsymlink
Symlink of file:
55057538 lrwxrwxrwx 1 prashant prashant 31 Nov 15 14:57 testsymlink -> /home/prashant/test/testsymlink
The Red mark nos. are the inode no of that file
$ Removing symlink will not affect the original file but if you remove original file then symlink will not work. the symlink will be changed to red color once original file removed
lrwxrwxrwx 1 prashant prashant 31 Nov 15 14:5te7 testsymlink -> /home/prashant/test/testsymlink