Linux ln command

Source: Internet
Author: User

Ln command: ln command is used to establish hard links and symbolic links.

Hard link:

$ Ln file1 file2

$ Cat file1 file2

 

We can see that file2 is exactly the same as file1. If you delete the file file1, the file file2 still exists. If you delete file2, the file file1 still exists. If you modify any file, the other file will be updated accordingly.

 

Symbolic Link:

$ Ln-s file1 file2

The difference between a symbolic link and a hard link is that a symbolic link only points to the name of the original file. If a symbolic link is deleted, the original file will not change. If you delete the original file, the symbolic link is useless.

A symbolic link has another advantage over a hard link: You can use a symbolic link to point to a word directory in the OpenLinux file system.

If you want to create a hard link to the subdirectory/usr/local/games,

$ Ln/user/local/games play

The ln command displays the error message and exits.

However, you can use symbolic links.

$ Ln-S/usr/local/games play

Now, you do not need to enter a command that is as long as the following:

$ CD/suer/local/games

You only need:

$ CD paly

Hard link disadvantage: cannot link to folders, cannot cross-filesystem.

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.