Linux LN commands use parameter details (ln-s soft link)

Source: Internet
Author: User

LN is a very important command in Linux, Its function is to create a synchronized link for a file in another location. When we need to use the same file in different directories, we don't need to put a file in every required directory, we just put the file in a fixed directory, and then The other directory uses the ln command to link it so that it does not have to use disk space repeatedly.

1. Command format:

ln [parameter] [source file or directory] [destination file or directory]

2. Command function:

Linux file system, there is so-called link, we can consider it as the alias of the file, and the link can be divided into two: Hard link and soft link (symbolic link), hard link means that a file can have multiple names, The soft link is the way to produce a special file, the contents of which is pointing to the location of another file. Hard links exist in the same file system, but soft links can span different file systems.

Soft Links:

1. Soft links, in the form of a path exists. Similar to shortcuts in the Windows operating system
2. Soft links can cross file system, hard links can not
3. Soft links can link to a nonexistent file name
4. Soft links can be linked to the directory

Hard Links:

1. Hard link, in the form of a copy of the file. But does not occupy the actual space.
2. Do not allow the creation of hard links to the directory
3. Hard links can only be created in the same file system

For example: Ln-s/bin/less/usr/local/bin/less "-S is the code name (symbolic) meaning"

here are two points to note:

First, the LN command maintains the synchronization of each linked file, meaning that no matter where you change it, the other files will change the same.
Second, Ln's links are soft links and hard links two, soft link is the ln–s source file destination file, it will only generate a file in your selected location image, will not occupy disk space, hard link ln source file destination file, no parameter-s, It will generate a file of the same size as the source file in the location you selected, whether it is a soft link or a hard link, and the file keeps changing synchronously.

If you use LS to look at a directory, found that there is a file at the end of a @ symbol, that is, a file generated with the LN command, with the ls-l command to see the link shown in the path.

The ln instruction is used in a linked file or directory, such as specifying more than two files or directories at the same time, and the final destination is a directory that already exists, and all of the previously specified files or directories are copied to the directory. If you specify multiple files or directories at the same time, and the final destination is not an existing directory, an error message appears.

3. Command parameters:

Necessary parameters:

-B Delete, overwrite previously established link
-D allows super users to make hard links to directories
-F Force Execution
-I interactive mode, file presence prompts the user whether to overwrite
-N treats symbolic links as generic directories
-S soft link (symbolic link)
-V displays detailed processing procedures

Select parameters:

-S "-s< tail backup string >" or "--suffix=< tail backup string >"

-V "-v< backup method >" or "--version-control=< backup method >"

--HELP Display Help information

--version displaying version information

Linux LN commands use parameter details (ln-s soft link)

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.