The Wayback Machine - https://web.archive.org/web/20240214081142/https://www.geeksforgeeks.org/difference-between-hard-link-and-soft-link/
Open In App
Related Articles

Difference between Hard link and Soft link

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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 Parameters Hard link Soft link
Inode number* Files that are hard linked take the same inode number. Files that are soft linked take a different inode number.
Directories Hard links are not allowed for directories. (Only a superuser* can do it) Soft links can be used for linking directories.
File system It cannot be used across file systems. It can be used across file systems.
Data Data 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 deletion If 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.
Speed Hard 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:

Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.


Last Updated : 07 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials