What is the difference between a hard link and a symbolic link?

Flavio Orlando
2 min readSep 15, 2020

--

  1. Soft Links (symbolic links)

You can make links to files and directories, and you can create links (shortcuts) on different partitions and with a different inode number than the original.

If the real copy is deleted, the link will not work.

A soft link (symbolic link) acts as a pointer or a reference to the file name. It does not access the data available in the original file. If the earlier file is deleted, the soft link will be pointing to a file that does not exist anymore.

2. Hard Links

Hard links are for files only; you cannot link to a file on a different partition with a different inode number.

If the real copy is deleted, the link will work, because it accesses the underlying data which the real copy was accessing.

A hard link acts as a copy (mirrored) of the selected file. It accesses the data available in the original file.
If the earlier selected file is deleted, the hard link to the file will still contain the data of that file.

How do I make a soft link?

A soft link can be made with ln -s; first you need to define the source and then you need to define the destination. (Keep in mind you need to define the full paths of both source and destination; otherwise it will not work.)

As you can see it has a different inode and can be made on a different partition.

How do I make a Hard link?

A Hard link can be made with ln; first you need to define the source and then you need to define the destination. (Keep it mind you need to define the full path of both source and destination; otherwise it will not work.)

Let’s say I have a script in the /script directory named firefox.

As you can see, it has the same inode. If I delete the original file, the link will still work, and it will act as the original.

--

--