Wednesday, December 1, 2010

What is the difference between Hard Link and Soft Link 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

No comments: