50-LN Concise Notes

Source: Internet
Author: User

Establish a link to a file

ln [options] existing-file [new-link]

ln [options] existing-file-list directory

LN can create a hard-link or symbolic (soft) link for one or more files. For a table of contents, you can create only symbolic links, not hard links

Parameters

First format:existing-file is the pathname of the file to create the link to, andNew-link is the path name of the new link. When you create a symbolic link,existing-file can be a directory.

If new-linkis omitted, LN creates a link in the working directory for Existing-file , using the same file name as existing-file

Second format:existing-file-list is the list of path names for the normal file to create the link,ln creates a new link in directory directory with the same link name as the original file name

Options

-B If you need to create a target link that already has the same file name, the backup

-F Force Create a target link

-I prompt when overwriting the same file name

-S creating Symbolic links

Attention

Hard Links: By default, LN creates hard links that are indistinguishable from the original file and cannot point to the directory. All hard links to the same file must be in the same file system,

Symbolic Links: Symbolic Links can point to directories and can reside in different file systems

ExampleLN Creates a hard link
$ ln/home/siu/backupname.sql. $ ls-l Total Usage 0-rw-r--r--2 siu siu 0  January  7 13:01 backupname.sql

This creates a hard link to a file in the current directory, followed by a. can also omit

Ln-s Creating Symbolic Links
$ ln-s/tmp/./abc$ ls-l Total dosage 0lrwxrwxrwx 1 siu siu 5  January  8 20:07 ABC-/tmp/

A symbolic link has been created for/tmp here/ABC

LN-SB
$ LN-SB AA bb$ ls-l total dosage 0-rw-r--r--1 siu siu 0  January  8 20:11 aalrwxrwxrwx 1 siu Siu 2  January  8 20:11 BB-A a-rw-r--r--1 siu Siu 0  January  8 20:11 bb~

Create symbolic links and back up existing files

LN-SF
$ ln-s AA CCLN: Unable to create symbolic link "cc": File already exists $ LN-SF AA cc$ ls-l Total usage 0-rw-r--r--1 siu siu 0  January  8 20:11 aalrwxrwxrwx 1 si U Siu 2  January  8 20:11 bb, aa-rw-r--r--1 siu siu 0  January  8 20:11 bb~lrwxrwxrwx 1 siu Siu 2  January 
   
    8 20:13 cc-A AA
   

Force creation of Symbolic links

Ln-si
$ ln-si AA bbln: Do you want to replace "BB"? y$ ls-l Total dosage 0-rw-r--r--1 siu siu 0  January  8 20:14 aalrwxrwxrwx 1 siu Siu 2  January  8 20:14 BB-AA

Prompt when creating a symbolic link

Tips

1. Hard links are usually the same as normal files, and cannot distinguish between their links

2. Hard link Size property as with the original file, if you delete the original file, hard links can also be used

3. Hard links have some limitations, so the scope of the symbolic link is more widely used

50-LN Concise Notes

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.