Linux du(全称为 disk usage)命令用于查看目录或文件所占用的磁盘空间。
该命令会列出指定目录或文件的具体磁盘使用情况。
du [-abcDhHklmsSx][-L ][-X ][--block-size][--exclude=][--max-depth=][--help][--version][目录或文件]
常用参数说明:
查看当前目录下各个文件和目录的磁盘使用情况:
# 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 .
上述结果显示了当前目录下各子目录和文件的大小,最后一行的 1288 表示整个目录的总大小。
查看单个文件的大小:
# du log2012.log 300 log2012.log
以更直观的方式查看 test 目录的使用情况:
# 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