Linux file system and DF command __linux

Source: Internet
Author: User
Tags parent directory

Http://www.cnblogs.com/itech/archive/2012/05/15/2502284.html

The DF command is used to display the available disk space on a disk partition. The default display unit is KB. You can use this command to get how much space the hard disk is occupied and how much space is left.

When the system disk is full, the most common command to view system space is df-i display inode information Di-ah m for the unit display disk utility information

Where the inode represents the area where the file information is stored, the Chinese is called an index node, and each file generates some information to be stored in the inode. When there are many small files in the disk, the Inode area may be full before the new file can be created. The inode also consumes disk space, so when the hard disk is formatted, the operating system automatically divides the hard disk into two areas. One is the data area, which holds the file data, and the other is the Inode table, which holds the information that the inode contains.

Each inode has a number, and the operating system uses the Inode number to identify the different files.

It is worth repeating that the Unix/linux system does not use the filename, and the inode number is used to identify the file. For systems, filenames are just nicknames or nicknames that are easily identifiable by inode numbers. On the surface, the user opens the file by file name. In fact, the process within the system is divided into three steps: First, the system finds the inode number corresponding to the file name, and secondly, obtains the inode information through the inode number, and finally, according to the Inode information, locate the block where the file data resides and read the data.

The inode contains the meta information of the file, specifically the following: * File bytes * File owner's user ID * file's group ID * file's read, write, execute permission * The timestamp of the file, there are three: CTime refers to the time the inode last changed,   Mtime refers to the last time the file content was changed, atime the time the file was last opened. * Number of links, that is, how many filenames point to the location of the inode * file data block
Hard links under normal circumstances, the filename and inode number is a "one by one correspondence" relationship, each inode number corresponds to a filename. However, the Unix/linux system allows multiple filenames to point to the same inode number. This means that you can access the same content with different file names, and modifying the contents of the file affects all file names, but deleting a file name does not affect access to another file name. This situation is referred to as a "hard link" (hard link).

The ln command can create a hard link: ln source file target file after running the above command, the source file has the same inode number as the target file, pointing to the same inode. An inode message is called a "number of links", which records the total number of file names that point to the inode, and then increases by 1. Conversely, deleting a filename causes the "Number of links" in the Inode node to be reduced by 1. When this value is reduced to 0, indicating that no file name points to the Inode, the system reclaims the inode number and its corresponding block area.

By the way, here are the number of links to the directory file. When you create a directory, two directory entries are generated by default: "." and ".." The inode number of the former is the inode number of the current directory, which is equivalent to the "hard link" of the current directory, and the inode number is the inode number of the parent directory of the current directory, which is equivalent to the "hard link" of the parent directory. So, the total number of "hard links" for any directory is always equal to 2 plus the total number of subdirectories (including hidden directories), where 2 is the "hard link" of the parent directory and the ". Hard link" under the current directory.

Soft links In addition to hard links, there is a special case. The inode number for file A and file B is different, but the content of file A is the path to file B. When you read file A, the system automatically directs the visitor to file B. Therefore, whichever file is opened, the final read is file B. At this point, file A is referred to as the "soft link" (soft link) or symbolic link (symbolic link) of file B.

This means that file a depends on file B, and if you delete file B, 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 filename, not the inode number of file B, and the Inode "link number" of File B does not change.

The ln-s command can create soft links. Ln-s source file or directory destination file or directory

The special role of inode because of the separation of inode number and filename, this mechanism leads to some phenomena peculiar to unix/linux system. 1. Sometimes, the file name contains special characters and cannot be deleted normally.   At this point, directly delete the Inode node, you can play the role of deleting files.   2. Move or rename the file, just change the file name without affecting the inode number. 3. After opening a file, the system identifies the file with the Inode number and no longer considers the filename.       Therefore, generally speaking, the system cannot know the filename from the inode number. The 3rd makes the software update simple, can be updated without shutting down the software, do not need to restart. Because the system through the Inode number, identify the running files, not through the filename. Update, the new version of the file with the same file name, to generate an inode, will not affect the running of the file. Wait until the next time the software is run, the file name will automatically point to the new version of the file, the old version of the file's inode is recycled.



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.