Nguyen links and hard links under the ln command

The difference between "ln -s libtensorflow_framework.so.1 libtensorflow_framework.so" and "ln libtensorflow_framework.so.1 libtensorflow_framework.so" is:

 "ln -s" creates a symbolic link (symbolic link), which only contains the path of the target file, and will be redirected to the target file when accessing the link file.
 "ln" creates a hard link (hard link), which contains the inode and data block information of the target file, accessing the hard link and the target file are equivalent.

So the main differences are: 1. Symbolic links can cross file systems, but hard links cannot. Hard links can only be created on the same file system.

2. After deleting the target file, the symbolic link becomes invalid, but the hard link is still available. Because hard links contain references to file data blocks.

3. Symbolic links can point to directories, but hard links cannot. 4. The number of links to the file is equal to the number of hard links plus 1 (the original file). Symbolic links do not affect the link count. In our case, use the symbolic link created by ln -s, which points to the libtensorflow_framework.so.1 file.
If you delete libtensorflow_framework.so.1 afterwards, the libtensorflow_framework.so symlink will become invalid. And if you use ln to create a hard link, even if you delete the libtensorflow_framework.so.1 object file, the libtensorflow_framework.so hard link is still valid because the file data it references still exists. So for the case of library files, creating symbolic links is a better choice. Because what we want is to trick the compiler into using the target library file at the linking stage, without modifying the data of the target file. In short, the main difference between ln -s and ln is that the types of links created are different. The former creates symbolic links, while the latter creates hard links. Selecting the corresponding link type according to the usage scenario can better achieve the expected effect.

Guess you like

Origin blog.csdn.net/u010087338/article/details/131052506