Linux du Command
The Linux du (full English: disk usage) command is used to display the size of directories or files.
du displays the disk space occupied by the specified directories or files.
Syntax
du [-abcDhHklmsSx][-L <符号连接>][-X <文件>][--block-size][--exclude=<目录或文件>][--max-depth=<目录层数>][--help][--version][目录或文件]
Parameter Description:
- -a or --all Display the size of individual files in the 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 size 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 -h, but K, M, G are based on 1000 as the conversion unit.
- -k or --kilobytes Use 1024 bytes as the unit.
- -l or --count-links Count hard-linked files repeatedly.
- -L<symbolic link> or --dereference<symbolic link> Display the size of the source file of the symbolic link specified in the option.
- -m or --megabytes Use 1MB as the unit.
- -s or --summarize Display only the total size of the specified directory or file, not the size of its subdirectories.
- -S or --separate-dirs When displaying the size of individual directories, do not include the size of their subdirectories.
- -x or --one-file-xystem Use the file system at the start of processing as the basis; skip directories on other different file systems.
- -X<file> or --exclude-from=<file> Specify directories or files in <file>.
- --exclude=<directory or file> Skip the specified directory or file.
- --max-depth=<directory levels> Ignore directories beyond the specified number of levels.
- --help Display help.
- --version Display version information.
Examples
Display the space occupied by directories or files:
# 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 directory 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 the specified file
# du log2012.log 300 log2012.log
Display the space usage of the test directory in a human-readable 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 testOther Extensions
Linux Command Reference