Soft link and hard link

Source: Internet
Author: User

Before understanding soft links and hard links, you must first understand some basic concepts.
File: file name + Data
In Linux, files are divided into two parts: user data and metadata.
User Data: file data block, which is the place where the recorded data is actually stored.
Metadata: The append attribute of the stored file (inode node number is stored in the metadata). inode is the unique identifier of the file, not the file name. The file name is just for convenience.
Inode: In a Linux file system, the system will assign an inode node number to the file category stored on the disk, which is called an index node, hard links are linked through index nodes.
The index node (inode) is unique only in the same file system. When multiple file systems are attached to a Linux system, the same index node may occur, therefore, hard links cannot be created across file systems.
Hard link: All links point to the same index node. Ln F1 F2
Soft link: Create an index node. Ln-s F1 F2.
Soft connection: the index nodes of the soft connection are allocated separately, and the data block of the node stores the path name of the linked file pointing. Therefore, soft links are also common files, but the content is a bit special and stores the path of another file.
Note: When a soft connection is established, it is better to direct the path to an absolute path, in case the link cannot become a dead link after it is moved.

I understand why links are used here. I am a little familiar with the linked list in C. Hard links are equivalent to many pointers pointing to the same memory address, the soft link is a double pointer pointing to a pointer pointing to the memory address.

Soft link and hard 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.