What is the Difference Between a Hard Link and a Symbolic Link?

Adam Taylor
2 min readFeb 7, 2021

Hard links and symbolic links in a Linux based operating system are similar in some ways, yet different in many others. Let’s start with what exactly a hard link is and how they are created. Think of a hard link as a mirror copy of the original file it is linked to. In Linux, we use and interact with our files using objects called links. These are essentially a means to associate a certain name with a file. When you create a new file, a hard link is also created associated with that file’s name with something that is known as an inode. An inode is a data structure that holds a unique ID within it’s own file system that contains file metadata such as what device the file resides on. If you were to somehow create a new file without a hard link pointing to an inode, the file is considered lost. Now, the biggest difference here is that symbolic links reference paths, instead of inodes. With linking to paths, comes linking to different file systems. If you were to ever remove a symbolic link, you are taking no risks, as a file can function without a symbolic link. On the other hand, if you were to remove a hard link from it’s original file, the file will be removed alongside the link. The only way for this to not happen is to have a separate hard link pointing to the same file to take it’s place. With this, symbolic links can actually point to non-existent files or directories, but you wouldn’t ever want to do this, as this renders the link broken.

--

--