Linux du command
The Linux du (short for disk usage) command is used to display the size of directories or files.
du displays the disk space occupied by the specified directory or file.
Syntax
du [-abcDhHklmsSx][-L <符号连接>][-X <文件>][--block-size][--exclude=<目录或文件>][--max-depth=<目录层数>][--help][--version][目录或文件]
Parameter Description:
- -a or -all Display the size of individual files in a directory.
- -b or -bytes Display directory or file sizes in bytes.
- -c or --total In addition to displaying the size of individual directories or files, also display the total of all directories or files.
- -D or --dereference-args Display the size of the source file of the specified symbolic link.
- -h or --human-readable Use K, M, G units to improve readability.
- -H or --si Same as the -h parameter, but K, M, G use 1000 as the conversion unit.
- -k or --kilobytes Use 1024 bytes as the unit.
- -l or --count-links Count files with hard links repeatedly.
- -L
or --dereference Display the size of the source file of the symbolic link specified in the options. - -m or --megabytes Use 1MB as the unit.
- -s or --summarize Display only the total size of the specified directory or file, without showing the sizes of its subdirectories.
- -S or --separate-dirs When displaying the size of individual directories, do not include the sizes of their subdirectories.
- -x or --one-file-xystem Use the file system at the start of processing as the standard; skip any directories on other file systems.
- -X
or --exclude-from= In Specify the directory or file. - --exclude=
Skip the specified directory or file. - --max-depth=
Directories beyond the specified level are ignored. - --help Display help.
- --version Display version information.
Example
Display the space occupied by a directory or file:
# du
608 ./test6
308 ./test4
4 ./scf/lib
4 ./scf/service/deploy/product
4 ./scf/service/deploy/info
12 ./scf/service/deploy
16 ./scf/service
4 ./scf/doc
4 ./scf/bin
32 ./scf
8 ./test3
1288 .
Only display the sizes of subdirectories under the current directory and the total size of the current directory; the 1288 at the bottom is the total size of the current directory
Display the space occupied by a specified file
# du log2012.log
300 log2012.log
Display the space occupied by the test directory in an easy-to-read format:
# du -h test
608K test/test6
308K test/test4
4.0K test/scf/lib
4.0K test/scf/service/deploy/product
4.0K test/scf/service/deploy/info
12K test/scf/service/deploy
16K test/scf/service
4.0K test/scf/doc
4.0K test/scf/bin
32K test/scf
8.0K test/test3
1.3M test
Linux Command Reference