Soft link and Hard link

  • symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of the original file.
  • If you delete the original file, the soft link has no value, because it points to a non-existent file. But in the case of hard link, it is entirely opposite.
  • Even if you delete the original file, the hard link will still has the data of the original file. Because hard link acts as a mirror copy of the original file.

In a nutshell, a soft link

  • can cross the file system,
  • allows you to link between directories,
  • has different inode number and file permissions than original file,
  • permissions will not be updated,
  • has only the path of the original file, not the contents.

In a nutshell, a hard link

  • can’t cross the file system boundaries (i.e. A hardlink can only work on the same filesystem),
  • can’t link directories,
  • has the same inode number and permissions of original file,
  • permissions will be updated if we change the permissions of source file,
  • has the actual contents of original file, so that you still can view the contents, even if the original file moved or removed.

View the Symbolic link on file system (ln stands for LiNk i.e soft and hard links)

ls -lia

Command to create a softlink

ln -s source.file softlink.file

Command to create a hardlink

ln source.file hardlink.file

More details on symbolic link

man ln

Leave a Comment