Linux常用命令(二十八)du

本文发布时间: 2019-Mar-22
Linux du命令也是查看使用空间的,但是与df命令不同的是Linux du命令是对文件和目录磁盘使用的空间的查看,还是和df命令有一些区别的.1.命令格式:du [选项][文件]2.命令功能:显示每个文件和目录的磁盘使用空间。3.命令参数:-a或-all 显示目录中个别文件的大小。-b或-bytes 显示目录或文件大小时,以byte为单位。-c或--total 除了显示个别目录或文件的大小外,同时也显示所有目录或文件的总和。-k或--kilobytes 以KB(1024bytes)为单位输出。-m或--megabytes 以MB为单位输出。-s或--summarize 仅显示总计,只列出最后加总的值。-h或--human-readable 以K,M,G为单位,提高信息的可读性。-x或--one-file-xystem 以一开始处理时的文件系统为准,若遇上其它不同的文件系统目录则略过。-L<符号链接>或--dereference<符号链接> 显示选项中所指定符号链接的源文件大小。-S或--separate-dirs 显示个别目录的大小时,并不含其子目录的大小。-X<文件>或--exclude-from=<文件> 在<文件>指定目录或文件。--exclude=<目录或文件> 略过指定的目录或文件。-D或--dereference-args 显示指定符号链接的源文件大小。-H或--si 与-h参数相同,但是K,M,G是以1000为换算单位。-l或--count-links 重复计算硬件链接的文件。4.命令实例:实例一. 显示目录或文件所占空间命令:du说明:只显示当前目录下面的子目录的目录大小和当前目录的总的大小,最下面的1288为当前目录的总大小[root@localhost test]# du608 ./test6308 ./test44 ./scf/lib4 ./scf/service/deploy/product4 ./scf/service/deploy/info12 ./scf/service/deploy16 ./scf/service4 ./scf/doc4 ./scf/bin32 ./scf8 ./test31288 .[root@localhost test]#实例二. 显示指定文件所占空间命令:du log2012.log[root@localhost test]# du log2012.log 300 log2012.log[root@localhost test]#实例三. 查看指定目录的所占空间命令:du scf[root@localhost test]# du scf4 scf/lib4 scf/service/deploy/product4 scf/service/deploy/info12 scf/service/deploy16 scf/service4 scf/doc4 scf/bin32 scf[root@localhost test]#实例四. 显示多个文件所占空间命令:du log30.tar.gz log31.tar.gz[root@localhost test]# du log30.tar.gz log31.tar.gz 4 log30.tar.gz4 log31.tar.gz[root@localhost test]#实例五. 只显示总和的大小命令:du -s[root@localhost test]# du -s1288 .[root@localhost test]# du -s scf32 scf[root@localhost test]# cd ..[root@localhost soft]# du -s test1288 test[root@localhost soft]#实例六. 以方便阅读的格式显示命令:du -h test[root@localhost soft]# du -h test608K test/test6308K test/test44.0K test/scf/lib4.0K test/scf/service/deploy/product4.0K test/scf/service/deploy/info12K test/scf/service/deploy16K test/scf/service4.0K test/scf/doc4.0K test/scf/bin32K test/scf8.0K test/test31.3M test[root@localhost soft]#实例七. 文件和目录都显示命令:du -ah test[root@localhost soft]# du -ah test4.0K test/log31.tar.gz4.0K test/test13.tar.gz0 test/linklog.log0 test/test6/log2014.log300K test/test6/linklog.log0 test/test6/log2015.log4.0K test/test6/log2013.log300K test/test6/log2012.log0 test/test6/log2017.log0 test/test6/log2016.log608K test/test60 test/log2015.log0 test/test4/log2014.log4.0K test/test4/log2013.log300K test/test4/log2012.log308K test/test44.0K test/scf/lib4.0K test/scf/service/deploy/product4.0K test/scf/service/deploy/info12K test/scf/service/deploy16K test/scf/service4.0K test/scf/doc4.0K test/scf/bin32K test/scf4.0K test/log2013.log300K test/log2012.log0 test/log2017.log0 test/log2016.log4.0K test/log30.tar.gz4.0K test/log.tar.bz24.0K test/log.tar.gz0 test/test3/log2014.log4.0K test/test3/log2013.log8.0K test/test34.0K test/scf.tar.gz1.3M test[root@localhost soft]#实例八. 显示几个文件或目录各自占用磁盘空间的大小,并统计它们的总和命令:du -c log30.tar.gz log31.tar.gz[root@localhost test]# du -c log30.tar.gz log31.tar.gz 4 log30.tar.gz4 log31.tar.gz8 总计[root@localhost test]#实例九. 按照空间大小排序命令:du|sort -nr|more[root@localhost test]# du|sort -nr|more1288 .608 ./test6308 ./test432 ./scf16 ./scf/service12 ./scf/service/deploy8 ./test34 ./scf/service/deploy/product4 ./scf/service/deploy/info4 ./scf/lib4 ./scf/doc4 ./scf/bin[root@localhost test]#实例十. 输出当前目录下各个子目录所使用的空间命令:du -h --max-depth=1[root@localhost test]# du -h --max-depth=1608K ./test6308K ./test432K ./scf8.0K ./test31.3M .[root@localhost test]#原文:http://www.cnblogs.com/peida/archive/2012/12/10/2810755.html


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表