What is the difference between soft link and hard link in Unix/Linux?

1 Answers
Answered by suresh

Unix Administrator Interview Question: Difference between Soft Link and Hard Link in Unix/Linux

Difference between Soft Link and Hard Link in Unix/Linux

Soft Link (Symbolic Link):

  • Soft links are similar to shortcuts in Windows.
  • Soft links are simply pointers to the original file or directory.
  • Deleting the original file does not affect the soft link, but the soft link becomes a dangling link.
  • Soft links can point to files/directories on different file systems.
  • Symbolic links display the target file or directory when viewed using ls -l command.

Hard Link:

  • Hard links are references to the inode of the original file on the disk.
  • Deleting the original file does not affect the hard link as the data is still accessible through the hard link.
  • Hard links cannot point to directories or files on different file systems.
  • When you create a hard link, it shares the same inode number as the original file.
  • Hard links do not show the target file when viewed using the ls -l command.

It is important to note the distinction between soft links and hard links when managing files in Unix/Linux systems for efficient file organization and maintenance.

Answer for Question: What is the difference between soft link and hard link in Unix/Linux?