Explain the difference between hard links and soft links in Unix/Linux.

1 Answers
Answered by suresh

Unix Administrator Interview Question: Difference between Hard Links and Soft Links

Explain the Difference between Hard Links and Soft Links in Unix/Linux

Hard Links:

  • Hard links are multiple directory entries pointing to the same physical location on the disk.
  • They share the same inode number and file content with the original file.
  • If the original file is deleted, the hard link will still remain and the data will be accessible.
  • Changes made to the original file will be reflected in all hard links.
  • Cannot be created for directories or across different file systems.

Soft Links (Symbolic Links):

  • Soft links are pointers to the original file or directory's path.
  • They have their own inode number and a separate entry on the disk.
  • If the original file is deleted, the soft link will become orphaned and will not work.
  • Changes made to the original file will not affect the soft link.
  • Can be created across different file systems and can link to directories.

In summary, hard links point directly to the physical location of the file content, while soft links point to the file's path in the directory structure.

Answer for Question: Explain the difference between hard links and soft links in Unix/Linux.