Soft Link and Hard Link in Linux
ln -s
: Soft link
Let’s make soft link to the test
as test2
morty@c137:~$ ln -s test test2
morty@c137:~$ ls -i
2759545 test2 2759449 test
-
Does depend on original file
-
Soft link has a different inode from inode of original
-
Linking existing file to new file
-
Linking between different file system
-
Linking a directory to another directory
ln
: Hard link
Let’s make hard link to the test
as test3
morty@c137:~$ ln test test3
morty@c137:~$ ls -i
2759545 test2 2759449 test3 2759449 test
-
Doesn’t depend on original file
-
Hard link has a same inode to the inode of original
-
Linking existing file to new file
-
Linking in same file system
-
Hard link can’t link directory