Linux du命令用于显示目录或文件的大小。
du 的英文原义为 disk usage,含义为显示磁盘空间的使用情况,用于查看当前目录的总大小。
du会显示指定的目录或文件所占用的磁盘空间。
语法:
du [-abcDhHklmsSx][-L <符号连接>][-X <文件>][--block-size][--exclude=<目录或文件>][--max-depth=<目录层数>][--help][--version][目录或文件]
参数说明:
显示目录或者文件所占空间:
# 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
# du -sh
605M .
# du log2012.log
300 log2012.log
Linux df命令用于显示目前在Linux系统上的文件系统的磁盘使用情况统计。
语法
df [选项]... [FILE]...
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 29640780 4320704 23814388 16% /
udev 1536756 4 1536752 1% /dev
tmpfs 617620 888 616732 1% /run
none 5120 0 5120 0% /run/lock
none 1544044 156 1543888 1% /run/shm
# df test
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 29640780 4320600 23814492 16% /
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda6 29G 4.2G 23G 16% /
udev 1.5G 4.0K 1.5G 1% /dev
tmpfs 604M 892K 603M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.5G 156K 1.5G 1% /run/shm