Ln command learning in linux

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.