What is a hard and symbolic (soft) link in Linux or Unix?

Hard link vs Soft link:

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
  • 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.

Check the inodes and permissions of symbolic link:

Check the inodes and permissions of hard link:

How do I create symbolic link in Linux?

To create a symbolic link to a given file, open your terminal and type using

How do I create hard link in Linux?

To create a hard link use the ln command as follows:

And that’s it!

Symbolic and hard links are very useful tools and are very easy to use.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store