ln
This is a very important command in Linux, please be familiar with it. Its function is to establish a different link for a file at another location. The most commonly used parameter of this command is -s, and the specific usage is: ln -s source file, target file.
When we need to use the same file in different directories, we do not need to put a file that must be the same in each required directory. We just need to put the file in a fixed directory, and then link it with the ln command in other directories, without having to take up disk space repeatedly. For example: ln -s /bin/less /usr/local/bin/less
-s is the code name (symbolic).
There are two points to note here: First, the ln command will maintain the synchronization of each linked file, that is, no matter which place you change, other files will undergo the same changes; second, the ln link is soft link and hard link. The soft link is ln -s ****. It will only generate a file image at the location you selected and will not occupy disk space. The hard link ln ****, without parameter -s, it will generate a file with the same size as the source file at the location you selected. Whether it is a soft link or a hard link, the file will remain synchronously changed. Soft links can cross partitions, but hard links can only be found in the same partition.
If you use ls to view a directory and find that some files have an @ symbol after it, it is a file generated with the ln command. Use the ls-l command to view it, and you can see the path of the displayed link.
This is a very important command in Linux, please be familiar with it. Its function is to establish a different link for a file at another location. The most commonly used parameter of this command is -s, and the specific usage is: ln -s source file, target file.
When we need to use the same file in different directories, we do not need to put a file that must be the same in each required directory. We just need to put the file in a fixed directory, and then link it with the ln command in other directories, without having to take up disk space repeatedly. For example: ln -s /bin/less /usr/local/bin/less
-s is the code name (symbolic).
There are two points to note here: First, the ln command will maintain the synchronization of each linked file, that is, no matter which place you change, other files will undergo the same changes; second, the ln link is soft link and hard link. The soft link is ln -s ****. It will only generate a file image at the location you selected and will not occupy disk space. The hard link ln ****, without parameter -s, it will generate a file with the same size as the source file at the location you selected. Whether it is a soft link or a hard link, the file will remain synchronously changed. Soft links can cross partitions, but hard links can only be found in the same partition.
If you use ls to view a directory and find that some files have an @ symbol after it, it is a file generated with the ln command. Use the ls-l command to view it, and you can see the path of the displayed link.