Difference between hard link and symbolic link
Ricardo Monta?a
Desarrollador Full Stack | Python | JavaScript | MySQL | HTML | CSS | Angular | ReactJS. Creación de soluciones innovadoras y escalables.
Hard Link Definition
Hard links directly link two files on the same file system and use the file's inode number for identification. Hard links cannot be implemented on directories (since they point to inode). When the " ln " command is used to generate a hard link, it creates another file on the command line that can be used to refer to the original file. Both the original and the generated file have the same inode and content; Therefore, they will have the same permissions and the same owner.
Deleting the original file does not affect the linked file, and a linked file will remain. The inode has a counter, to calculate the number of hard links to itself. When the counter returns a value of 0, the inode is flushed. Whenever you make changes to the hard link, it will be mimicked in the original file
Symbolic Link Definition
Symbolic links are usually an alternate path (or alias) to the original file; these are also known as symbolic links. Includes the name of the "target file" of the link, a flag that specifies that it is a soft link. When a file is accessed, the soft link redirects it to the destination file via the path written in the subject of the soft link.
These are very useful in the case of Windows OS, where the soft link behaves like shortcuts. The creation and removal of soft links do not affect the original file. If the target file is deleted, the soft link hangs, which means it points nowhere and generates an error message when the target file is accessed. Soft links do not use inode number, unlike hard link. An absolute or relative path could be a part of symbolic links.
领英推荐
?Key Differences Between Hard Link and Symbolic Link
3.???Hard links are restricted to their own partitions, but soft links can cover different file systems.
4.???Hard link performance is better than soft link in some cases.
5.???Relative path and absolute path are allowed in soft links. In contrast, the relative path is not allowed on a hard link
Conclusion
A hard link requires no additional space and the mesh resolves faster, but changes made to a hard link are reflected in the original file. On the other hand, the soft link needs additional space, but any change to the soft link does not affect the original file. Soft links are allowed to directories unlike Hard link.