What is the difference between a hard link and a symbolic link?
There are two types of links in UNIX system, hard link and soft links, also known as symbolic link or symlink.
Though both points to some other source, there are a lot of difference between them. Hard link is direct pointer to the inode of the original file. If you compare the original file with the hard link there won’t be any differences between them. On other hand, a soft link is a file that have the information to point to another file or inode. That inode points to the data in the disk.
Hard links are much more restrictive than soft links and that’s why they are used rarely. Also not all file systems supports hard links but UNIX does.
A) The target of the the hard link must exist, which is not mandatory in case of soft link. A soft link is said broken if target link doesn’t exists.
B) Unlike soft link which are mostly created to reference directories e.g. current link pointing to latest release, Hard links are generally not allowed on directories.
C) One more critical difference between soft link and Hard link is that hard links are not allowed to cross partitions or volumes. Therefore, they cannot exist across file systems.
D) A hard link looks, and behaves, like a regular file, so they can be hard to find. On the other hand soft links are quite different than regular files.
E) A hard link is, for all intents and purposes, the same entity as the original file. They have the same file permissions, time stamps, and so on. All attributes are identical.