1. What is the difference between a symbolic link and a hard link?
-
A file in the file system is basically a link to an inode.
-
A hard link, then, just creates another file with a link to the same underlying inode.
A symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of the original file.
If you delete the original file, the soft link has no value, because it points to a non-existent file.
But in the case of hard link, it is entirely opposite. Even if you delete the original file, the hard link will still has the data of the original file.
Because hard link acts as a mirror copy of the original file.
When you delete a file, it removes one link to the underlying inode. The inode is only deleted (or deletable/over-writable) when all links to the inode have been deleted. |
Hard links are only valid within the same File System. Symbolic links can span file systems as they are simply the name of another file. |