每天一个Linux命令(31):du
来源:互联网 发布:现货白银软件 编辑:程序博客网 时间:2024/06/06 11:47
与df不同的是,du是对文件和目录使用磁盘空间的查看。
1. 命令格式
du [选项][文件]
2. 命令功能
显示文件或目录的磁盘使用空间。
3. 命令参数
-a或-all,显示所有文件和目录的大小,默认输出单位为byte。
-b,–bytes,显示目录或文件大小时,以byte为输出单位。
-c,–total,显示所有目录或文件的总和,会在输出的末尾出现“xxx 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,显示目录的大小时,并不含其子目录。
–exclude = <目录或文件> ,略过指定的目录或文件。
-D或–dereference-args,显示指定符号链接的源文件大小。
-H,–si,与-h参数相同,但是K,M,G以1000为换算单位。
-l或–count-links,重复计算硬件链接的文件。
4. 使用实例
例一:显示目录或文件占用的空间
命令:du
# du608 ./test6308 ./test44 ./scf/lib4 ./scf/service/deploy/product4 ./scf/service/deploy/info12 ./scf/service/deploy16 ./scf/service4 ./scf/doc4 ./scf/bin32 ./scf8 ./test31288 .
说明:显示当前目录的大小及其子目录的大小,最下面的1288为当前目录的大小。
例二:显示指定文件所占空间
命令:du log2012.log
# du log2012.log 300 log2012.log
例三:查看指定目录的所占空间
命令:du scf
# du scf4 scf/lib4 scf/service/deploy/product4 scf/service/deploy/info12 scf/service/deploy16 scf/service4 scf/doc4 scf/bin32 scf
例四:显示多个文件所占空间
命令:du log30.tar.gz log31.tar.gz
# du log30.tar.gz log31.tar.gz 4 log30.tar.gz4 log31.tar.gz
例五:只显示总和的大小
命令:du -s
# du -s1288 .# du -s scf32 scf# cd ..# du -s test1288 test
例六:方便阅读的格式显示
命令:du -h test
# 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
例七:文件和目录都显示
# 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
例八:显示几个文件或目录各自占用磁盘空间的大小,还统计它们的总和
命令:du -c log30.tar.gz log31.tar.gz
# du -c log30.tar.gz log31.tar.gz 4 log30.tar.gz4 log31.tar.gz8 总计
说明:加上-c选项后,du不仅显示目录各自占用的磁盘空间,还在最后一行统计总和。
例九:按照空间大小排序
命令:du | sort -nr|more
# 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
例十:在当前目录下,输出各个子目录使用的磁盘空间
命令:du -h --max-depth=1
# du -h --max-depth=1608K ./test6308K ./test432K ./scf8.0K ./test31.3M .
- 每天一个Linux命令(31):du
- 每天一个linux命令,DU
- 每天一个linux命令:du 命令
- 每天一个linux命令:du 命令
- linux每天一个命令:du命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个linux命令(34):du 命令
- 每天一个 Linux 命令(34):du 命令
- 每天一个Linux命令(34):du命令
- 每天一个 Linux 命令(34):du 命令
- 每天一个linux命令(34):du 命令
- js arguments和caller,callee
- mysql 常见函数总结
- Nginx-------Nginx的安装和多域名配置
- redis 安装
- Maven学习:常用mvn命令
- 每天一个Linux命令(31):du
- Maven scope含义的说明
- js RegExp对象学习结合字符串replace方法使用
- 判断字符串是否包含某个子字符串的方法
- AIDL与IPC学习总结
- Maven构建简单的多模块项目
- BridgeWebView的简单使用,自动调用js的代码
- CSS 工作总结(nobr标签可以防止换行)
- js 点击input弹出选择框