Link file is a short cut file to the original file. There are two types of links files available in Linux. The links in Unix like OS are essentially the pointers which associate to the files and directories. Here we will see the difference between Soft Links and Hard Links in linux.
There are two types of link files available in Linux.
- Soft Link
- Hard Link
- Soft link is a short cut file. If original file deleted, there is no use of short cut file. ie. we can’t access the original data by selecting link file.
- Soft link can be applied on both files and directories.
- Soft Link files can be stored in any file system. ie., the original file can be in one file system and the link file can be on another file system. If we edit any file, the linked files are also updated automatically.
- When we create a soft link file, there are are full permissions always.
- The soft link file and the original file inode numbers are different.
- The size of the soft link file is same as the length of the original file name.
Soft link can be created using following commands.
$ ln -s (to create a soft link)
$ ln -s /root/script /root/Desktop/script (to create a link file for the script and stored on root Desktop)
- Hard link in nothing but a backup file. If the original file is deleted, there is no effect on hard link file. ie. we can access the original file data even though the link file is deleted.
- Hard links can be applied on files only not on directories.
- Hard link files can be stored on the same file system. ie., original and hard link files both should be in the same file system not on different file systems.
- The inode numbers are same for original and hard link files.
- If the original is edited, the updations are applied on both original and hard link files.
- The size of the hard link file is same as the size of the original file.
Hard links can be created using following commands.
/root/file /root/Desktop/file(to create a hard link)
Hence we learned difference between Soft Links and Hard Links in Linux.
I hope I helped !!
Read Also : Difference Between File Systems in Linux