Centos users often ask why the results of using du and df to View disk capacity are inconsistent, whether there are bugs or disk fragments, or which result should prevail. In fact, the values obtained by the two commands are inconsistent because the implementation of the du command is different from that of the df command, rather than the fault. [Root @ www ~] # Du-sh/home4.7G/home [root @ www ~] # Df-h/homeFiles
Centos users often ask why the results of using du and df to View disk capacity are inconsistent, whether there are bugs or disk fragments, or which result should prevail. In fact, the values obtained by the two commands are inconsistent because the implementation of the du command is different from that of the df command, rather than the fault.
[Root @ www ~] # Du-sh/home
4.7 GB/home
[Root @ www ~] # Df-h/home
Filesystem Size Used Avail Use % Mounted on
/Dev/sda5 15G 4.9G 8.9G 36%/home
[Root @ www ~] #
As you can see, the/home partition capacity is 4.9 GB for df and 4.7 GB for du.
Run the du-s command to accumulate the total number of directories, symbolic links, and blocks used by the specified file system.
The df command displays the disk block distribution graph of the file system to obtain the total number of blocks and the remaining number. The file system allocates some disk blocks to record some of its own data, such as I nodes, disk distribution charts, indirect blocks, and super blocks. This Data is invisible to most user-level programs, usually referred to as Meta Data.
The du command is a user-level program that does not consider Meta Data, while the df command checks the disk distribution diagram of the file system and considers Meta Data. Df command to obtain the real file system data, while du command to view only part of the file system.
Df shows the disk usage. The "-h" option can be output in units such as KB, MB, and GB. The "-H" option can also be output in units such as KB, MB, and GB, but the "1000B" option is 1KB, instead of 1024B