Linux Basics

You are currently auditing this course.
81 / 107

Hard link and soft link

A link in UNIX is a pointer to the file. It is a connection between a file name and the actual data on the disk. It is of two types:

  1. Hard links

  2. Soft links (Symbolic links)

Hard link is the mirror copy to the original file. It means that even if the file is moved or deleted, the hard link will still contain the data of the original file. This is because the hard link is assigned the same inode value as the original file.

Inode value- Whenever a file is created in linux, an inode value is assigned to it. It is a unique index number assigned to each file in Linux/Unix system. When we access the file by its filename, internally, it is accessed through its inode value.

On the other hand, a soft link is just a reference to another file or directory. It just contains the path to the original file and not the content. If the original file is moved or deleted, the link will point to a non-existent file. This is because soft links are assigned a different inode number.

enter image description here

So, as we can see in the above diagram that even if the original file is deleted, hard link will still point to the same inode value. On the other hand, soft link will be broken as it doesn't have any direct connection with the inode value of the original file.

We use ln command to make link. It by default creates hard link. For symbolic link, we use ln -s.


No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...