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
Summary du common commands
Du-h--max-depth=1 |grep [TG] |sort #查找上G和T的目录并排序
Du-sh #统计当前目录的大小, showing in an intuitive way
Du-h--max-depth=1 |grep ' G ' |sort #查看上G目录并排序
Du-sh--max-depth=1 #查看当前目录下所有一级子目录文件夹大小
Du-h--max-depth=1 |sort #查看当前目录下所有一级子目录文件夹大小 and sorting
Du-h--max-depth=1 |grep [TG] |sort-nr #倒序排
This article introduces the usage of the du command parameter in Linux, and illustrates its usage further with demonstration examples.
Du command feature Description: Statistics the size of the disk space that a folder (or file) occupies.
Syntax: du [-ABCDHHKLMSSX] [-l < Symbolic connection >][-x < file >][--block-size][--exclude=< folder or file] [--max-depth=< Number of folder layers >][-
-help][--version][folder or file]
Frequently used parameters:
-A or-all displays disk usage for each of the specified files, or displays the respective disk usage for each file in the folder.
-B or-bytes displays the folder or file size in bytes.
-C or –total displays the sum of all folders or files in addition to the size of the folder 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 repeatedly calculates hardware connections.
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 folder size.
When-S or –separate-dirs displays the size of each folder, it does not contain the size of its subfolders.
-X or –one-file-xystem the file system at the start of the process, and if you encounter a different file system folder, skip.
-x< file > or –exclude-from=< file > specify folder or file in < file >.
–exclude=< folder or File > skips the specified folder or file.
–max-depth=< folder layers > folders that exceed the specified number of layers are ignored.
–help display Help.
–version Displays version number information.
The du command in Linux uses a demo example:
1> to display disk usage for a folder tree and each subtree
Du/home/linux
This displays the number of disk blocks in the/home/linux folder and each subfolder.
2> to display the disk usage of a folder tree and each subtree in 1024 bytes
Du-k/home/linux
This displays the number of 1024-byte disk blocks in the/home/linux folder and each subfolder.
3> Displays the disk usage of a folder tree and each subtree in MB
du-m/home/linux
This displays the number of MB disk blocks in the/home/linux folder and each subfolder.
4> Displays the disk usage of a folder tree and each subtree in gigabytes
Du-g/home/linux
This displays the number of GB disk blocks in the/home/linux folder and each subfolder.
5> View the size of all folders and subfolders under the current folder:
Du-h.
“.” Represents the current folder. can also be replaced with a clear path.
-H represents the humanized form of K, M, and G
6> View the size of the user folder under the current folder, and do not want to look at other folders and their subfolders:
Du-sh User
-S indicates the meaning of the summary, That is, simply listing a summarized value,
du-h--max-depth=0 user
--max-depth=n, indicates that the only depth to the N-tier folder is set to 0, which means that it is not drill-down to subfolders.
7> Lists the size of all folders and files under the user folder and its subfolders:
Du-ah User
-A to include folders and files
8> lists the size of folders in the current folder that do not contain XYZ strings:
Du-h–exclude= ' *xyz* '
9> want to list a number of other information about the user folder and subfolder size in one screen:
du-0h user
-0 (bar 0) means that each folder is listed with information, not wrapped, Instead, you output the information for the next folder directly.
10> only displays all disk usage for one folder tree
Du-s/home/linux
The above is a small series to introduce the Linux du command to see folder size and in descending order of all the narration, I hope you like.