Hard links and Symbolic links — easy explanation

Andres Pulido
3 min readJun 9, 2020
Difference between hard link and symbolic link references

Hard and symbolic links refer to a file in the same hard drive and those methods are part of any filesystem that organizes what it is in each file and where. A hard link is usually a synced copy of a file that refers directly to the inode of a file. Symbolic links, on the other hand, direct to the file which refers to the inode which is a shortcut.

What is an inode:

Here is where the fun begins, an inode is a small database that describes the file or directory characteristics such physical location or metadata on the same hard drive, This is a numerical equivalent of a full address location of a file. With an inode, the operating system can later retrieve pretty much all the information in regards to the file such as user permissions, file privileges and the physical location of the data on the hard drive.
If the file is moved from one folder to another, this will be moved to a different location on the hard drive and its unique inode value will be swap bt another one automatically each time this happens.

What is a hard link?

In computing, a hard link is a directory entry that associates a name with a file on a file system and all directory-based file system must have one hard link giving the original name of each file.

Creating the first file ‘test’ before making a hard link test2

In the previous screenshot, the hard link to a file is created using the command line to create a hard link named test2 with the command ‘ln test test2’

The file ‘test’ should be empty but the file ‘test2’ will contain some text: “Holberton is awesome”,

Opening test 2 with Holberton is awesome! in it

Now the change from the hard link made in ‘test2' is reflected in the original file ‘test’ as is shown in the following

The change from the hardlink is reflected in the original file

I have changed the original file via the hard link by adding “Holberton is awesome”. By opening the original file, the word “Holberton is awesome” is already in there.

What are symbolic links:

In computing, a symbolic link is a term for any file that contains a reference to another file or directory in the form of an absolute or relative path, in other words, it contains a string that automatically interpreted and followed by the operating system as a path for another directory as a shortcut that reference to a file instead of its inode value.

--

--