Linux_ Link File

Source: Internet
Author: User
Tags parent directory

Link concept:

is divided into soft links and hard links, the file type is L

Hard Link: ln source file Destination file

Soft Link: ln-s source file Destination file (destination file cannot exist beforehand)

Ln-s/root//tmp/root    # Create a soft link to the/root directory to the/tmp directory under Readlink/tmp/root        # to indicate the link chain to address touch test.sh    # to create test data in ln test. sh/tmp/test.sh    # Create a hard link ll-i test.sh  /tmp/test.sh     # Check the i node of two files

  

Hard Links:

Hard links are linked through the index node, in the Linux system, multiple file names point to the same index node is normal and allowed, the case of the file is called hard link, hard link equivalent to another entry of the file, establish a hard link to prevent accidental deletion, there is backup effect

Ln/etc/hosts/tmp/oldboy.host          #对于这个文件, create a hard link, or you can say that a new entry was created for a file/tmp/oldboy.host

Link Knowledge Summary:

  1. Multiple files with the same Inode node number are hard-linked files, creating a hard link that is equivalent to a file entity with multiple entries
  2. Only delete the source file and all corresponding hard link files, the file entity will be deleted, delete one or several hard links from the source file, the file entity will not be deleted. When the deletion succeeds, the file location is not re-occupied or fsck is checked before the file data is likely to be recovered
  3. Prevent critical files from being mistakenly deleted by creating hard links to files
  4. Hard-link files when normal files can be deleted by RM
  5. Static file (no process is called), I_link is 0, the file will be deleted
  6. Delete the source file, the soft link file still exists, but cannot find the file, it will blink red and white
  7. Multiple soft links point to the same file, single these soft link inode different, belong to different files
  8. Soft links have the same file type as L, hard-link file types and source files

Links to files:

1. The file can create a hard link, adding a file entry, but creating a hard link cannot span partitions

2. Files can create soft links, but only in the sibling directory, out of sibling directory invalidation

3. The filename itself is a hard link, but also a file entry

For directory Links

    1. Directories cannot create hard links, directories can create soft links
    2. Soft links to catalogs are often used in production scenarios, with less hard links
    3. There will be two hard links in each directory. Current directory,.. Parent Directory

Link Summary:

  

 1. Create a hard link for a file, add a file read data entry, create a soft link to a directory, and access the directory directly via a soft link

2. Delete the source file name, as long as there is a hard link to the source files, through the hard link or can access to the data, and has not been deleted, why?

   

When I_link = 0 and I_count = 0, it is like putting the file data into a small black room, being recycled, and deleting

3. Remove the soft link, no impact on the source file, delete the source file name, the soft link to the source files is invalid

4. Hard links point to the same inode, soft links have their own inode and block

  

Linux_ Link File

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.