Live as if you were to die tomorrow. Learn as if you were to live forever.

Friday 23 January 2015

What is the difference between soft and hard links ?

Soft Link:

1. Soft link having different inode number.
2. Soft link can cross file system boundaries.
3. In soft link we can link to files as well as directories.
4. Soft link will break if original file is moved or deleted.
5. Size of the soft link file is the length of the original file.

[root@localhost vinod]# ln -s new.pl softlink.pl
[root@localhost vinod]# ll new.pl softlink.pl
-rw-r--r--. 1 root root 610 Jan  4 23:24 new.pl
lrwxrwxrwx. 1 root root   6 Jan 23 03:44 softlink.pl -> new.pl
[root@localhost vinod]#


Hard Link:

1. Hard link having same inode number.
2. Hard link can not cross file system boundaries.
3. In Hard link we can only link to files but we cannot link to directories.
4. Hard link cannot break even if you delete or move the original file.
5. Size of hard link file is equal to the length of the original file.


[root@server vinod]# ln pass.sh hardlink.sh
[root@server vinod]# ll pass.sh hardlink.sh
-rw-r--r--. 2 root root 36 Dec 31 22:40 hardlink.sh
-rw-r--r--. 2 root root 36 Dec 31 22:40 pass.sh
[root@server vinod]#



No comments:

Post a Comment