Use of the Linux command ln

Source: Internet
Author: User

LN is a very important command in Linux, it is the function of a file in another location to establish a link, the most common parameter of this command is-s, the specific use 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. For example: Ln–s/bin/less/usr/local/bin/less-s is the meaning of the codename (symbolic).

Here are two points to note: first, the LN command will maintain the synchronization of each linked file, that is, no matter where you change the other files will change the same; second, Ln's links are divided into soft links and hard links two, soft link is ln–s * *, It will only generate a mirror image of a file in the location you selected, take up a small amount of disk space (link address information), Hard link LN * *, no parameter-s, it will generate a file in your chosen location with the same size as the source file, whether it is a soft link or a hard link, the file will remain synchronized changes.


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.


Instruction details
Directive name: LN
usage rights: All users
Usage: ln [options] Source dist, where option is in the format:
[-BDFINSVF] [-S backup-suffix] [-v {numbered,existing,simple}]
[--help] [--version] [--]
Description: Linux/unix file system , there are so-called links, we can think of 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, and the soft link is to produce a special file, The contents of this file refer 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 to produce a link (dist) to source, and the use of a hard or soft link is determined by the parameter.
either hard or soft links do not copy the original file, only taking up a very small amount of disk space.
-F: Link to the file with the same file name Dist deleted
-D: Allow the System Manager to hard-link their own directory
-I: When deleting the file with the dist file with the first query
-N: When the soft link, the dist as a normal file Case
-S: Soft link (symbolic link)
-V: Display its file name before linking
-B: Files that will be overwritten or deleted at the end of the link
-s SUFFIX: Add the backed up files to the SUFFIX br>-V Method: Specify how the Backup
--help: Show Secondary description
--version: Show version


Example:
Generates a symbolic Link:link file
Ln-s File Link
The directory dir produces a symbolic link:link
Ln-s dir link
Creates a hard Link:link file
ln file link
The directory dir is generated with a symbolic link:link and overwritten if link already exists. Can be used when deploying different versions of the service, reducing downtime
LN-SF File Link

Use of the Linux command ln

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.