Differences between soft connections and hard connections in UNIX systems

Source: Internet
Author: User
I have never understood UNIX systems Hard connectionAnd Soft connectionIn my spare time, when I was bored, I wanted to exercise and read some computer materials in English.

To clarify the differences between the two, we must first understand the file storage in UNIX systems. File storage in UNIX files can be divided into three parts:

1. File Name;

2. inode stores the attributes of this file, including the file size, owner, and access permissions.

3. data block data;

Here is an example:

Target file name/opt/public. cSoft connectionThe name is A, and the createdHard connectionIs B.

In this case, the/opt/public. c file is stored as follows: 1. The file name is public. C 2 and inode is 1233.

3. Data blocks are the data blocks of files.

ThenSoft connectionA is stored as follows: 1. File Name: A 2. inode is 1423 (system assigned value) 3. data block data is/opt/public. C.

WhileHard connectionB's storage is: 1. File Name: B 2. inode is 1233. 3. data block is the data block of the file.

From above we knowSoft connectionHas its own inode and data block. The content in the data block is the absolute or relative path of the file to be connected. WhileHard connectionThe same inode and data block as the file to be connected.

The differences between the two connections are mainly reflected in the access permission.Soft connectionThe access permission is 777, but this is not his actual access permission. The actual access permission is based on the access permission of the file connected to him. WhileHard connectionWhen a file is created, the access permission is the access permission connected to it, because they share an inode, And the inode stores the access permission for the file.

What needs to be added is,Soft connectionCross-file system, whileHard connectionCross-file system is not supported.

View a file or directoryHard connectionNumber of available LS-Al

Drwxr-XR-x 10 jlivr other 512 Jun 9.
Drwxrwxr-x 13 root sys 512 Apr 11 ..
-RW ------- 1 jlivr other 3442 Jun 9. bash_history
-RW-r -- 1 jlivr other 1039 May 11. Profile
Drwxr-XR-x 2 jlivr other 512 Apr 26 Bin
Drwxr-XR-x 3 jlivr other 1024 Apr 26 Inc
Drwxr-XR-x 2 jlivr other 512 Apr 26 lib
Drwxr-XR-x 8 jlivr other 512 Jun 6 MEX
Drwxr-XR-x 2 jlivr other 1024 May 20 new_voice
Drwxr-XR-x 2 jlivr other 512 May 23 006 OBJ

There is a number between the access permission and the file owner, which indicates the file or directoryHard connectionQuantity.

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.