What is a Soft Link or Symbolic Link or Symlink ?
Soft links are very similar to what we say “Shortcut” in windows, is a way to link to a file or directory. Symlinks doesn’t contain any information about the destination file or contents of the file, instead of that, it simply contains the pointer to the location of the destination file. In more technical words, in soft link, a new file is created with a new inode, which have the pointer to the inode location of the original file. This can be better explained with a diagram:
Soft links are created with "ln" command with "-s" option I will show you an example:
I have a file named "file1.txt", This is the original file. From this i am going to create a soft link file.
Next i will show you the content in both the file
Next iam goig to make changes in original file then you can see how the hard linked file affect that changes.
Next i am going to delete the original file then we can see what changes are occur
If we delete the original file then it will affect the soft linked file
What is a Hard Link ?
Hard link is a bit different object when compared to a symlink. In softlink a new file and a new Inode is created, but in hard link, only an entry into directory structure is created for the file, but it points to the inode location of the original file. Which means there is no new inode creation in the hard link. This can be explained like this:
I have a file named "file1.txt", This is the original file. From this i am going to create a hard link file.
Next i will show you the content in both the file
Next iam goig to make changes in original file then you can see how the hard linked file affect that changes.
Next i am going to delete the original file then we can see what changes are occur
No comments:
Post a Comment