Soft connection command ln -s in Linux

Soft link:

Soft link (softlink) is also called symbolic link (Symbolic Link). The soft link file in linux is similar to the shortcut in windows system. It's actually a special file. In a symbolic link, the file is actually a text file that contains information about the location of another file. In the operating system, it is similar to the concept of the index. The location information of the real file is stored in the index i node, which can also be compared with the pointer in C++. In short, the real file is accessed through the address to achieve the purpose of reducing memory. After all, one file is enough.

Linux creates a connection command ln -s soft link:

         This is a very important command in linux, please be familiar with it. Its function is to establish a different link for a certain file in another location. The most commonly used parameter of this command is -s,

The specific usage is: ln -s source file target file.

When we need to use the same file in different directories, we don't need to put a file that must be the same in every required directory, we just need to put the file in a fixed directory, and then in other You can use the ln command to link (link) it in the directory, and you don’t have to take up disk space repeatedly. Where -s is the symbolic meaning.

Precautions:

There are two things to note here:

First, the ln command will maintain the synchronization of each linked file, that is, no matter which one you change, the same changes will occur in other files;

Second, second, there are two types of ln links: soft link and hard link. The soft link is ln -s ** **, it will only generate a mirror image of the file at the location you selected, and will not occupy disk space , hard link ln ** **, no 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 keep changing synchronously.

Specific usage:

  -f : When linking, delete the file with the same file name as dist

  -d : Allow system administrators to hardlink their own directories

  -i : Ask first when deleting a file with the same file name as dist

  -n : Treat dist as a normal file when making soft links

  -s : make a soft link (symbolic link)

  -v : display the filename before linking

  -b : Backup files that will be overwritten or deleted at link time

  -S SUFFIX : add the suffix of SUFFIX to the backup files

  -V METHOD : Specifies the backup method

  --help : display helper help

  --version : show version

Guess you like

Origin blog.csdn.net/chenthe1/article/details/131276544