Difference between soft links and hard links in Linux

Hi Friends, We have always little bit of confuse about hard link and soft link. I am trying to clear confusion. Let’s see difference between soft links and hard links in Linux. Explaining the difference between a symbolic link or a symlink and a hard link is easy and vital to knowing about how Linux/Unix environments work.

There are 2 types of links that you can create within Linux:

Hard Links
Symbolic Links

A symbolic link is much like a desktop shortcut within Windows. The symbolic link merely points to the location of a file.
A hard link is actually the same file that it links to but with a different name. It’s share the same inode.

Difference between soft links and hard links in Linux

Difference between soft links and hard links in Linux

 Hard link:Hard link refers to "The specific location of physical 
data".

•  Hard Link is a mirror copy of the original file.
•  Hard links share the same inode.
•  Any changes made to the original or Hard linked file will reflect the other.
•  Even if you delete any one of the files, nothing will happen to the other hard links.
•  But soft link which points to deleted hard link become a dangling soft link.
•  You can't link a directory even within the same file system.
•  Hard links can't cross file systems.
 Soft link( also called symbolic link):Soft link refers to "A symbolic 
path indicating the abstract location of another file".

•  Soft Link is a symbolic link to the original file.(more like windows shortcuts)
•  Soft Links will have a different Inode value.
•  Any changes made to the soft link will reflect the original file and its hard links.
•  A soft link points to the original file. If you delete the original file, the soft link fails. It would become dangling symbolic link.
•  If you delete the soft link, nothing will happen.
•  You can link a directory using soft link on same file system and also on other file system.
•  Soft links can cross file systems

Enjoy ?

Tagged , , . Bookmark the permalink.