1. Df-lh
2. Du-s/usr/* | Sort-rn
This is sorted by byte
3. du-sh/usr/* | Sort-rn
This is sorted by megabytes (M)
4. Select 10 of the preceding
Du-s/usr/* | Sort-rn | Head
5. Select the following 10
Du-s/usr/* | Sort-rn | Tail
Du-h–-max-depth=0 User
du-sh–-max-depth=2 | More
This article describes in detail the usage of the du command parameters in Linux, and uses the examples to further illustrate their usage.
Du command Feature Description: The size of the disk space that the statistics directory (or file) occupies.
Syntax: du [-ABCDHHKLMSSX] [L < Symbolic connection >][-x < file >][--block-size][--exclude=< directory or file] [--max-depth=< number of directory layers >][--help][--version][directory or file]
Common parameters:
-A or-all displays disk usage for each specified file, or displays the respective disk usage for each file in the directory.
-B or-bytes displays the directory or file size in bytes.
-C or –total displays the sum of all directories or files in addition to the size of the directory or file.
-D or –dereference-args displays the source file size for the specified symbolic connection.
-H or –human-readable to k,m,g to improve the readability of the information.
The-H or –si is the same as the-h parameter, but the k,m,g is in 1000 as the conversion unit instead of 1024.
-K or –kilobytes in 1024 bytes.
-L or –count-links a file that calculates hardware connections repeatedly.
The source file size for the symbol connection specified in the-l< symbol connection > or –dereference< symbol connection > Display option.
-M or –megabytes is in 1MB.
-S or –summarize displays only totals, that is, the current directory size.
When-S or –separate-dirs displays the size of each directory, it does not contain the size of its subdirectories.
-X or –one-file-xystem the file system at the start of the process, and if you encounter a different file system directory, skip.
-x< files > or –exclude-from=< files > specify directories or files in < file >.
–exclude=< directory or File > skips the specified directory or file.
–max-depth=< the directory layer > beyond the specified number of layers, ignored.
–help display Help.
–version Displays version information.
Example of using the Du command in Linux:
1> to display disk usage for a directory tree and each subtree
Du/home/linux
This displays the number of disk blocks in the/home/linux directory and each of its subdirectories.
2> to display the disk usage of a tree and each subtree in 1024-byte units
Du-k/home/linux
This shows the number of 1024-byte disk blocks in the/home/linux directory and each of its subdirectories.
3> displays the disk usage of a directory tree and each subtree in MB
Du-m/home/linux
This shows the number of MB disk blocks in the/home/linux directory and each of its subdirectories.
4> displays the disk usage of a directory tree and each subtree in GB
Du-g/home/linux
This displays the number of GB disk blocks in the/home/linux directory and each of its subdirectories.
5> View the size of all directories and subdirectories under the current directory:
Du-h.
“.” Represents the current directory. can also be replaced with a clear path
-H indicates a humanized form of K, M, and G
6> View the size of the user directory under the current directory and do not want to look at other directories and their subdirectories:
Du-sh User
-S means the summary, which lists only one summarized value
Du-h--max-depth=0 User
--max-depth=n represents a depth to the N-tier directory, which is set to 0, meaning that it is not drill-down to subdirectories.
7> lists the size of all directories and files under the user directory and its subdirectories:
Du-ah User
-A representation includes directories and files
8> lists the size of directories in the current directory that do not include the XYZ string:
Du-h–exclude= ' *xyz* '
9> want to show more information about the user directory and subdirectory size in one screen:
du-0h User
-0 (Bar 0) represents the information for each directory that is listed, without wrapping, but directly outputting the information for the next directory.
10> displays all disk usage for only one directory tree
Du-s/home/linux