The difference between a hard link and a soft link

Source: Internet
Author: User

Hard Link LN:

The Unix file system provides a mechanism for linking different files to the same file, called links. It allows a single program to use different names for the same file. The benefit is that the file system only has a copy of the file. The system simply implements this link by creating a new login entry in the directory. The login entry has a new file name and the inode number of the file to be linked (the inode is the same as the original file). No matter how many hard links a file has, there is only one inode on the disk that describes it, so long as the number of connections to the file is not 0, the file remains there. Hard links cannot establish hard links to directories.

A hard link is built directly on the node table (inode), and when a hard link is established to a file, the count value above the node table is updated. Eg, a file is linked two times (LN), the value of this file is 3, and regardless of the 3 filenames of any one is accessed, the effect is the same, but if you delete any one, only the value minus 1, does not delete the actual content (any existing file itself is a hard link), only the count value becomes 0 o'clock, To actually delete the content.

Soft links (Symbolic link) ln-s:

Symbolic links become soft links. It is a special file that points to another file whose data part contains only the pathname of the file to which it is linked. Soft links in order to overcome the lack of hard links introduced, soft links do not directly use the Inode number as a file pointer, and the use of file path name as a pointer (soft link: File name + data section-the path of the destination file). The soft link has its own inode, and there is a small space on the disk to store the path name. As a result, soft links can be linked across file systems and directories. Second, a soft link can link to a nonexistent file name, but it is not possible to open a link until it has been created.

~ Wakahara file deleted, the soft link cannot be accessed, hard links can also.

The difference between a hard link and a soft link

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.