The Art of Writing Short Stories Read Here

Difference between Hard link and Soft link

 Hard Link :

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.

Soft Link :
A soft link (also known as 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.

Some notable differences between the two are listed below:

Comparison ParametersHard linkSoft link
Inode number*Files that are hard linked
take the same inode number.
Files that are soft linked
take a different inode number.
DirectoriesHard links are not
allowed for directories.
(Only a superuser* can do it)
Soft links can be used for
linking directories.
File systemIt cannot be used
across file systems.
It can be used
across file systems.
DataData present in the original
file will still be available
in the hard links.
Soft links only point to the
file name, it does not retain
data of the file.
Original file’s deletionIf the original file is removed, the link
will still work as it accesses the data the
original was having access to.

If the original file is removed, the link
will not work as it doesn’t access the
original file’s data.
SpeedHard links are comparatively faster.Soft links are comparatively slower.

Note:

  • Inode number – Index node number is a unique number assigned to all files in a Linux/Unix system.
  • Superuser – A superuser has more rights compared to an ordinary user. They can change file ownership and set permissions.

Diagrammatic representation:


You may also like :