Article Title: Evaluate the disk usage of the file system: du. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
(Usually used to estimate the directory capacity)
[Root @ www ~] # Du [-ahskm] file or directory name
Options and parameters:
-A: lists all files and directory capacities, because only the files under the directory are counted by default.
-H: displayed in a readable capacity format (G/M;
-S: only list the total amount, rather than the capacity occupied by each directory;
-S: Does not include the total number of sub-directories, which is slightly different from-s.
-K: displays the capacity in KBytes;
-M: displays the capacity in MBytes;
Example 1: list all the file capacities under the current directory
[Root @ www ~] # Du
8./test4 <= each directory is listed
8./test2
... Omitted in the middle ....
12./. gconfd <= directory containing hidden files
220. <= total amount occupied by this directory (.)
# If du is directly input without any options, du will analyze the 'current directory'
# The disk space occupied by files and directories. However, only the directory capacity (excluding files) is displayed ),
# Therefore, many files in the directory are not listed, so the addition of all directories will not be equal to the capacity!
# In addition, the output value is a capacity unit of 1 kb.
Example 2: same example 1, but the file capacity is also listed
[Root @ www ~] # Du-
12./install. log. syslog <= list of files
8./. bash_logout
8./test4
8./test2
... Omitted in the middle ....
12./. gconfd
220.
Example 3: Check the capacity occupied by each directory under the root directory
[Root @ www ~] # Du-sm /*
7/bin
6/boot
... Omitted in the middle ....
0/proc
... Omitted in the middle ....
1/tmp
3859/usr <= He is the biggest guy in the system at the early stage!
77/var
# This is a frequently used Function ~ Each directory is represented by a ten-character,
# If you want to check the maximum capacity occupied by a directory, you can use this method to find out
# It is worth noting that if Linux is just installed, the maximum capacity of the entire system should be/usr
# While/proc has the listed capacity, but that capacity is in the memory and does not occupy the hard disk space.
Unlike df, The du command searches all archives directly in the file system, so the operation of the third example command will take a short time! In addition, under the Preset conditions, the capacity output is designed in KB. If you want to know how many MB the directory occupies, use the-m parameter ?? 《? If you only want to know how much capacity the directory occupies, use-s!
As for the "-S" option, the size of all files is listed by du by default. Therefore, if you use du under/etc, the sub-directory capacity under/etc will also be calculated once. Then the final Capacity (/etc) will be added once, so many friends will misunderstand that the results of du analysis are not too smooth. So ??? Why? Guan? Q: How can I replace ke xiaoluna? Kong Shixi may also be able to add the-S option to reduce the total number of sub-directories!