HardLinks & SymbolicLinks)

Source: Internet
Author: User
[Ln establishing a connection file] I mentioned the concept of two connection files. now I should introduce this part. There are two types of connection files: hardlink and symboliclink ). HardLinks: As mentioned above, when the system wants to read a file ,...
[Ln establishing a connection file] I mentioned the concept of two connection files. now I should introduce this part. There are two types of connection files: hard link and symbolic link ). Hard Links: As mentioned above, when the system wants to read a file, it first reads the inode table and then extracts the data from the block area based on the information in the inode. Hard link directly creates an inode to connect to the block area where the file is placed. That is to say, during hard link, the content of the file does not actually change, but an inode pointing to the file is added, but this will cause a problem, because the added inode connects to the block area, and the Directory itself only consumes inode, hard link cannot connect to the directory. Remember that hard link has two restrictions: 1. it cannot be used across file systems, because different file systems have different inode tables, and 2. it cannot be used to connect to directories.
Www.2cto.com Symbolic Links: Unlike hard link, this creates an independent file, which is used to read the connection file, it will forward the read behavior to the file linked to the file. In this case, it may be a detour, so let's take an example. Now there is file a. we have made a soft connection file B (only a connection file, very small), and B points to file. When B is read, B forwards the read Action to a, and then reads file. Therefore, when you delete File a, file B will not be deleted, but when you read file B again, the system will prompt that the file cannot be opened. However, when you delete B, a will not have any impact.
It seems that hard link is safer, because even if an inode is killed and any inode exists, the file will not be seen! However, unfortunately, due to too many restrictions on Hard Link, including links that cannot be used as directories, the usage is limited! The Symbolic Link is widely used! So how to establish a soft connection and a hard connection? The ln command is used. Ln syntax: ln [-s] [source file] [target file] common options of ln are-s. If it is not added, a hard connection is established, and a soft connection is established.
Before and after a hard connection is established at www.2cto.com, the space occupied by the 123 Directory has not changed. After the source file is deleted, the space remains unchanged. It indicates that deleting an object only deletes inode information. You cannot create a hard connection to a directory. After a soft connection is established, 4 K is added to the 456 directory to delete the source file, and the error "no such file" is returned. The directory can be soft-connected.
Deleting a soft connection on www.2cto.com does not affect the source file.
Related Article

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.