Linux File Link command

Source: Internet
Author: User

Ln command

This command creates a link between files. This operation is actually to specify another name that can be used to access an existing file in the system. For this new file name, we can specify different access permissions for it to control information sharing and security issues. If the link points to a directory, you can use the link to directly enter the directory to be linked without having to create a lot of path names. Besides, even if we delete this link, the original directory will not be damaged.

Syntax: ln [Option] target [Link name]

Ln [Option] target directory

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.

Example: $ ln-s lunch/home/Xu

The user creates a symbolic link/home/Xu for the file lunch in the current directory.

Delete a symbolic link. delete a symbolic link if it is created.

Rm-RF symbolic_name note not Rm-RF symbolic_name/

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.