Why use Hard and Soft link instead Copy files!!!

Cristian Bedoya Blanco
3 min readJun 10, 2020
Scheme of Hard & Soft link

Some times it’s very useful to have access to file in different places to the system file organization, now for skipping of creating copies en many parts Linux uses the links that are targeted in the original file. Links occupy less space and more efficient than copies. Linux has two kinds: Hard link & Soft link.

One of the most important advantages, when you modify one file wichs is linked to the other ones, the changes will be replied too.

Hard links

Hard links point to the content of the original file, for this reason, all of them share the same inode. On the other hand, a hard link is a duplicated entry into the file system in a different location for an existing file.

For creating a link we use “ln” command, first is create a new file called “hardlinktest”

so now we going to make the hard link /tmp directory.

For to check if each one has the same inode just type ls -li

inode = 18710743

We noted that 4 is the number of files linked! Important fact if you delete one file linked the other one could be a kind of “backup”

Soft link

In simple words, it’s an access route to a file. In consequence, if the original file is deleted every soft link will be broken.

For to do a symbolic link just type ls -s “destination” “symbolic”. Now o want to create a quick route from my working directory to a file /etc/passwd.

Then check de file using command cat

that's awesome !! I don't need now changing me of the working directory all of the time!

*inode is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory.

--

--

Cristian Bedoya Blanco

Materials Engineer and Software Developer. First that a professional i am humanistic person. I accepts and overcomes every single challenge.