Inode and soft-hard link analysis in Linux

Source: Internet
Author: User
Tags object object

     What is a . inode ? (index node)              Understanding inode  need to know the file storage, the file is stored on the hard disk , when the operating system reads the hard disk, it reads multiple sectors (the smallest storage unit of the hard disk) continuously, i.e. reads one block at a time (the smallest unit of file access). So the file data are stored in the block, you need a place to store the file management information. such as the creator of the file, the date the file was created, the size of the file, and so on. This area of stored file management information is called the Inode (Index node).            two. Content of   inode             1. The number of bytes of the file;         2. The uid of the file owner;        3.  gid of documents;          4.  File read, write, execute permission;        5. File timestamp, total three:ctime  refers to the time of the inode last change, mtime refers to the contents of the file last change        time, atime refers to the time the file was last opened,      6.  number of links, that is, how many filenames point to the inode;       7.  file Data Block location    You can use the Stat command to view inode information for a file:       [Object Object]    & nbsp;  three.  inode&nbsp, the size of the   inode will also consume hard disk space, so when the hard disk format, the operating system automatically divides the hard disk into two areas.  One is the       data area, storing the file data, and the other is the Inode area (inode table), which holds the information contained in the Inode.          the size of each inode node, typically 128 bytes or 256 bytes. The total number of inode nodes, given at the time of formatting,              An inode is set up every 1KB or every 2KB.              each inode has a number, and the operating system uses Inode numbers to identify different files.           about soft and hard links     a. Hard links         in general, the file name and inode number are the "one by one correspondence" relationship, and each inode number corresponds to a file name. However, the Unix      /linux system allows multiple filenames to point to the same inode number. This means that the same        content can be accessed with different filenames, and changes to the contents of the file affect all file names, but deleting a file name does not affect the other file name    Access to     . This is referred to as a "hard link".        two. The inode numbers for soft link        file A and file B are different, However, the content of file A is the path to file B. When you read file A, the system will be accessed from       The user-directed file B. Therefore, regardless of which file you open, the final read is file B. At this point, file A is called a "soft link" (soft link) of        file B or "Symbolic link         This means that file a depends on file B and if file B is deleted, opening file A will cause an error: "No such file or    directory". This is the biggest difference between soft links and hard links: file a points to file B's file name, not file B's inode number        code, and file B's Inode "link count" does not change.        difference between the two:       (1) Soft links can be &nbsp across file systems, and hard links are not available.        (2) questions about  inode  . Hard links no matter how many, all point to the same inode, will increase the number of inode links         as long as the inode link number is not  0, the file has been there, Whether you delete a source file or a linked file. As long as there is a          exist, the file exists (in fact, there is no point   source files linked files, because they are pointing to the same  inode)         &nbsp When you modify the source file or any of the linked files, and the other files are changed synchronously. Soft links do not directly allow        to use the inode number as a file pointer, but rather using the file path masterpiece as a pointer (soft links are not the same as the inode of the source file). So        Delete the link file has no effect on the source file, but delete the source file, the link file will not find the file to point to  。 The soft link has        own inode, and there is a small space on the disk to store the path name .       (3) Soft links can be linked to a nonexistent file name  .     (4) Soft links can be linked to a directory.

This article is from the "Output Diamond pattern" blog, so be sure to keep this source http://10541571.blog.51cto.com/10531571/1761738

Inode and soft-hard link analysis in Linux

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.