An explanation of ln link command under Linux

Source: Internet
Author: User

LN is another very important command in Linux, and its function is to create a different link for a file in another location, the most commonly used parameter of this command is-S, which is: ln–s source file Destination file.
When we need to use the same file in different directories, we do not need to put a file in each required directory, we just put the file in a fixed directory, and then in the other directory with the ln command link it can, do not have to repeatedly occupy disk space. Example: ln–s/bin/less/usr/local/bin/less
-S is the meaning of the Code name (symbolic).
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 links and soft links and hard links two, soft link is ln–s * * *, it will only be in the location you selected to generate a file image, does not occupy disk space, hard link LN * * *, no parameter-s, it will be in the location you selected to generate a file with the same size as the source file, Files are kept in sync, whether they are soft links or hard links.
If you use LS to look at a directory, found that there is a file behind a @ symbol and the color of the file or folder is not the same, I am blue on the machine, that is a file generated with the LN command, with the ls–l command to see the link shown in the path.
Instruction detailed description
Directive Name: LN
Usage rights: All users
How to use: ln [options] Source dist, where option is in the format:
[-BDFINSVF] [-S Backup-suffix] [-v {numbered,existing,simple}]
[--help] [--version] [--]
Note: In the Linux/unix file system, there is a so-called link, we can consider it as the alias of the file, and the link can be divided into two types: Hard link and soft link (symbolic link), hard link means that a file can have multiple names, The soft-link approach is to produce a special file with the content of the file pointing to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.
LN Source Dist is the generation of a link (dist) to the source, and the use of a hard or soft link is determined by the parameter.
Whether a hard link or a soft link will not copy the original file, it will only occupy a very small amount of disk space.
-F: Delete the file with the Dist file name at the end of the link
-D: Allow system managers to hard-link their own directories
-I: Ask before deleting the file with the Dist file name
-N: When making a soft link, treat the dist as a generic file
-S: Soft junction (symbolic Link)
-V: Displays the file name before the link
-B: Files that are overwritten or deleted at the time of the link are backed up
-S SUFFIX: Add the backed up files with SUFFIX tails
-V Method: Specify how the backup should be
--HELP: Show Auxiliary Instructions
--version: Display version
Example:
The file yy produces a symbolic link:zz
Ln-s yy ZZ
To create a hard link:zz file yy
ln yy XX
PS: If you want to delete a link, just like a normal file, the RM link name is the same.

An explanation of ln link command under Linux

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.