- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Hard link and Soft link
In computer networks, links are the pointers associated with files and directories. These links are of two types: Hard Links and Soft Links. A hard link is a direct reference to a file, while a soft link is a reference by name. Thus, a soft link points to a file by its file name.
Read this article to find out more about hard links and soft links and how they are different from each other. Let's start with a basic overview of hard links and soft links so that it becomes easier to differentiate them.
What is a Hard Link?
The method of direct linking of two files in a same file system is referred to as the hard link. Hard links use the index node (inode) number for the identification of a file. Since hard links point to inode, they cannot be implemented on directories.
The "ln" command is executed to create a hard link. This command creates another file on the command link that is used to refer the original one. Although, both the original file and the hard linked file have the same index node (inode) number and content. Consequently, both files have the same set of permissions and the same owner.
If we removed the original file, then it will affect the hard linked file. Thus, the hard linked file will exist even after the removal of the original file. Hard links consume less memory space and they can be linked only to its own partition. In the case of hard links, the relative paths are not allowed.
What is a Soft Link?
A file can be accessed through many references. All of this point to a specific file is known as a soft link. In other words, the link to a file in which the file is pointed by its file name is known as soft link. Thus, a soft link is an alias or alternate path to the original file. Soft link does not use index node (inode) number. Soft links are also referred to as a symbolic link, because they contain the name of the target file of the link.
While accessing the file through the soft link, it redirects the link to the target file through the path provided in the subject of the soft link. The major advantage of the soft link is that the deletion and creation of the soft links do not influence the original file. The soft links can have an absolute or relative path as their part.
Difference between Hard Link and Soft Link
The important differences between Hard Link and Soft Link are highlighted in the following table −
S. No. | Hard Link | Soft Link |
---|---|---|
1. | A file that has a hard link can be accessed using multiple names. These names are known as hard links. | A file can be accessed through many references. All of this point to a specific file known as a soft link. |
2. | Once the file is deleted, the link would still be valid. The file can be accessed even after it has been deleted. | Once the original file has been deleted, the link becomes invalid. |
3. | The inode number remains the same. | The inode number is different. |
4. | The command used to create a hard link is 'ln'. | The command to create a soft link is 'ln s'. |
5. | It consumes less memory. | It consumes more memory. |
6. | It can be linked to its own partition only. | It can be linked to other file systems and can be networked too. |
7. | It doesn't have a relative path. | It has a relative path. |
Conclusion
The most significant difference that you should note here is that a hard link is an alternate path of the original file that uses inode to access the target file, whereas a soft link is an alternate path to access the target file but does not refer inode to access it.
- Related Articles
- Difference Between Link and Association
- Difference Between Soft Computing and Hard Computing
- Difference Between Hard Water and Soft Water
- Difference between Hibernate and Eclipse link
- Difference between Hard Magnetic Material and Soft Magnetic Material
- Difference between ACL and SCO Link in Bluetooth
- What is the difference between URL and Link?
- The Link Between Migraine, Nausea, and Vomiting
- Hard and Soft Decision Decoding
- What is the difference between Point to Point Link and Star Topology Network?
- What is the link between Strategy and Capital Budgeting?
- The Link Between Uterine Fibroids and Heavy Menstrual Bleeding
- Difference between Hard Drive and Memory
- Difference between AI and Soft Computing
- What is the link between Phi and the Golden Ratio?
