Differences between hard links and symbolic links in linux

Source: Internet
Author: User
In practice, hard links and symbolic links (soft links) are difficult to distinguish, but they are indeed different: hard links can only be applied to files, not directories, in addition, it cannot be used across file systems (that is, partitions). Symbolic Links can be used for files and directories and cross-file systems (partitions). This is their difference in application; underlying differences: When we create a hard link to a file, the hard link uses the same inode number as the file, the number of inode connections in the original file has changed from 1 to 2. In fact, hard links and files use the same inode, but the number of inode connections has increased, and deleting files does not affect hard links, the number of hard-linked inode will change from 2 to 1. Let's take a look at the demonstration: when creating a soft link to a file, the soft link will use a new inode, therefore, the inode Number of the soft link is different from the inode Number of the file. The inode of the soft link stores the path pointing to the file, and deletes the file. The soft link cannot be used, because the file path does not exist, when we create this file again (the file name is the same as the previous one), the soft link will point to this file again (the inode number is different from the previous one ), hard links won't be affected. See the demo:

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.