As shown in the diagram soft links or symbolic links simply points to another file. It only contains the pathname of the file to which it is pointing
1. Creation method
# touch file # ln -s file link # ls -l -rw-r--r-- 1 root root 0 Sep 19 14:41 link
lrwxrwxrwx 1 root root 5Sep 19 15:41 link -> file
2. The size of the soft link created in the example above is the no of characters in the pathname (file), which is 5 (it can be absolute or relative).
3. If you delete the original file (file) the soft link render as useless.
4. Soft links can reside on different file systems.
5. You can create soft links to directories also.
Every file uses atleast one hard link. So when you create a new file a new directory entry is created which is called link count. So when you create a new hard link to this file the link count increaments by 1.
1. creation method
# touch file1 # ls -l -rw-r--r-- 1 root root 0 Sep 23 13:19 file1 # ln file1 file2 # ls -l -rw-r--r-- 2 root root 0 Sep 23 13:19 file1 -rw-r--r-- 2 root root 0 Sep 23 13:19 file2 # ls -li 1282 -rw-r--r-- 2 root 0 root 0 Sep 23 13:19 file1 1282 -rw-r--r-- 2 root 0 root 0 Sep 23 13:19 file2 # find . -inum 1282 ./file1 ./file2
2. The link count increases by one, everytime you create a new hard link to the file as shown above.
3. Even if you delete any one of the file, it has no effect on the other file. Only the link count decrements
4. Hard links can not cross the file system.
5. You can not create hard links to directories.