The Different Between Hard Link And Symbolic Link Unix
If you are into UNIX maybe you came across those or Soft link instead of symbolic and got asked about the different between them .
Hard Link : What Is It ?
A hard link is a direct reference to a file via its inode. You can also only hardlink files and not directories. By using a hardlink, you can change the original file’s contents or location and the hardlink will still point to the original file because its inode is still pointing to that file. There is no referencing to the original file. In addition, hardlinks can only refer to files within the same volume otherwise symbolic links will be needed. To make a hard link of a file, you will require the ln command and refer to the source file before naming what the hard link will be named.
Symbolic Link Or Soft Link : What Is It ?
Symbolic links are essentially shortcuts that reference to a file instead of its inode value. This method can be applied to directories and can reference across different hard disks/volumes. Since the symbolic link is referring to the original file and not its inode value, then replacing the original file into a different folder will break the symbolic link, or create a dangling link.
The Different
A Symbolic Link
- Can cross the file system,
- Allows you to link between directories,
- Has different inode number and file permissions than original file,
- Permissions will not be updated,
- Has only the path of the original file, not the contents.
A hard Link
- Can't cross the file system boundaries (i.e. A hardlink can only work on the same filesystem),
- Can't link directories,
- Has the same inode number and permissions of original file,
- Permissions will be updated if we change the permissions of source file,