Should I use Hard or Symbolic links?

Deyber Castañeda
2 min readJun 9, 2020

Usually we want to create a link that avoids us to create copies of a file on
every directory where we could need it.
But… What kind of link I should use?

Let’s to cosider the next:
In Unix-like operating systems such as Linux, “everything is a file” and a file is fundamentally a link to an inode (a data structure that stores everything about a file apart from its name and actual content).

A hard link is a file that points to the same underlying inode, as another file. In case you delete one file, it removes one link to the underlying inode. Whereas a symbolic link (also known as soft link) is a link to another filename in the filesystem.
Another important difference between the two types of links is that hard links can only work within the same filesystem while symbolic links can go across different filesystems.

If you want to create a soft link or symbolic link you can use ln and -s as option, for example:

ln -s filename linkname

Whereas if you want to create a hard link you sould use the following
command:

ln filename linkname

In this article, we’ve learned how to create hard and symbolic links in Linux
and the cases when is better to use anyone. You can ask any question(s) or share your thoughts about this guide.

--

--

Deyber Castañeda

Software Developer and Science lover always learning.