Hard vs Symbolic, a Look Into Links

Selidex Parnell
2 min readSep 14, 2020

Often in computer programming, a single file will be referred to as different names, called links. When talking in terms of Bash (our Unix shell/language) there are two types of links, hard links and symbolic links (also known as soft links). While both types have similar functions, there are several differences that separate the two, and I will detail out these differences here. To begin let us define a few terms.

ln- ln is our command to make both types of links, with the difference being the option used when creating the link.

inode- An inode is a unix data structure that stores a file or directories information such as location and attributes.

A hard link follows the format ln SOURCE DESTINATION, creating a link named DESTINATION that has the same inode as SOURCE. Hard link has a couple of major limitations. First offthe majority of systems will only allow a hard link to a file. In other words you can not hard link a directory. Second a hard link can only be made in the same partition in the system.The trade off is that if the original file is deleted the hard link still functions as it pointed to the data the file contains rather than pointing to the file itself.

A symbolic link follows a similiar format with one major exception: ln -s SOURCE DESTINATION, with -s being the option that causes the command to make a symbolic link instead of a hard link. Unlike a hard link, the symbolic does not point directly to the inode and points directly to the filename of the SOURCE instead. Because of this, if the orignal copy is deleted the symbolic link will no longer work. The trade off here is that you can point to either a file or a directory, and the link can point to something that is on a different partition in the system.

So while both links have similar features and are created in similar ways, they both have situations in which one would be used over the other, and can achieve different tasks.

--

--