symbolic link
A symbolic link contains a text string that is automatically interpreted and followed by the operating system as a path to another file or directory. This other file or directory is called the "target". The symbolic link is a second file that exists independently of its target. If a symbolic link is deleted, its target remains unaffected. If a symbolic link points to a target, and sometime later that target is moved, renamed or deleted, the symbolic link is not automatically updated or deleted, but continues to exist and still points to the old target, now a non-existing location or file. Symbolic links pointing to moved or non-existing targets are sometimes called broken, orphaned, dead, or dangling.
windows的快捷方式就是软链
hard link
In computing, a hard link is a directory entry that associates a name with a file in a file system. All directory-based file systems must have at least one hard link giving the original name for each file(基于目录的文件系统上的每个文件至少有一个硬链接,像我们在windows上天天看到的“文件路径”就是链接到文件的hard link). The term “hard link” is usually only used in file systems that allow more than one hard link for the same file.
Creating an additional hard link has the effect of giving one file multiple names (e.g. different names in different directories) all of which independently connect to the same data on the disk, none of which depends on any of the others.[1] This causes an alias effect: e.g. if the file is opened by any one of its names, and changes are made to its content, then these changes will also be visible when the file is opened by an alternative name. By contrast, a soft link or “shortcut” to a file is not a direct link to the data itself, but rather is a short file that contains the text of a file name, or a location that gives direct access to yet another file name within some directory. The name contained in or referred to by the soft link may either be a hard link or another soft link. This also creates aliasing, but in a different way.
一个文件可以有多个硬链,但它们链接到同一个文件,所以通过任意一个硬链对文件的修改会作用到其他硬链上,因为硬链只是同一文件的不同“名字”
网友评论