This is a very important command in linux. Please be familiar with it. Its function is to create a synchronization link for a file or directory in another location, similar to a hyperlink in Windows.
The most common parameter of this command is-s. The specific usage is:
Sudo ln-s source file target file
Example:
The current directory is/local, and I often want to access/usr/local/linux/work
Then I can create a file linkwork under local,
Then sudo ln-s/usr/local/linux/work/local/linkwork
That is, the link between the two is established.
Delete Link
Rm-rf symbolic_name note not rm-rf symbolic_name/So above I am rm-rf/local/linkwork
There are two types of links: Hard Link and Symbolic Link ). When creating a hard link, the linked file and the linked file must be in the same file system, and cannot establish a hard link to the directory. This problem does not exist for symbolic links. By default, ln generates hard links.
In the case of hard links, the "target" in the parameter is linked to the [Link name]. If the [Link name] is a directory name, the system creates one or more link files with the same name as the "target" under the directory, the content of the linked file is exactly the same as that of the linked file. If the [Link name] is a file, the user will be notified that the file already exists and will not be linked. If multiple "target" parameters are specified, the last parameter must be a directory.
If the-s option is added to the ln command, a symbolic link is established. If the [Link name] already exists but is not a directory, no link will be made. [Link name] can be any file name (including path), a directory, and allow it to be different from the target file system. If the [Link name] is an existing directory, the system creates one or more files with the same name as the "target" in the directory, the new file actually points to the symbolic link file of the original "target.