每日一linux命令 du [系列]
http://www.cnblogs.com/peida/archive/2012/12/10/2810755.html
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.使用实例:
实例1:显示目录或者文件所占空间
命令:
du
输出:
[root@localhost test]# 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 .
[root@localhost test]#
说明:
只显示当前目录下面的子目录的目录大小和当前目录的总的大小,最下面的1288为当前目录的总大小
实例2:显示指定文件所占空间
命令:
du log2012.log
输出:
[root@localhost test]# du log2012.log
300 log2012.log
[root@localhost test]#
说明:
实例3:查看指定目录的所占空间
命令:
du scf
输出:
[root@localhost test]# du scf
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
[root@localhost test]#
说明:
实例4:显示多个文件所占空间
命令:
du log30.tar.gz log31.tar.gz
输出:
[root@localhost test]# du log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
[root@localhost test]#
说明:
实例5:只显示总和的大小
命令:
du -s
输出:
[root@localhost test]# du -s
1288 .
[root@localhost test]# du -s scf
32 scf
[root@localhost test]# cd ..
[root@localhost soft]# du -s test
1288 test
[root@localhost soft]#
说明:
实例6:方便阅读的格式显示
命令:
du -h test
输出:
[root@localhost soft]# 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
[root@localhost soft]#
说明:
实例7:文件和目录都显示
命令:
输出:
[root@localhost soft]# du -ah test
4.0K test/log31.tar.gz
4.0K test/test13.tar.gz
0 test/linklog.log
0 test/test6/log2014.log
300K test/test6/linklog.log
0 test/test6/log2015.log
4.0K test/test6/log2013.log
300K test/test6/log2012.log
0 test/test6/log2017.log
0 test/test6/log2016.log
608K test/test6
0 test/log2015.log
0 test/test4/log2014.log
4.0K test/test4/log2013.log
300K test/test4/log2012.log
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
4.0K test/log2013.log
300K test/log2012.log
0 test/log2017.log
0 test/log2016.log
4.0K test/log30.tar.gz
4.0K test/log.tar.bz2
4.0K test/log.tar.gz
0 test/test3/log2014.log
4.0K test/test3/log2013.log
8.0K test/test3
4.0K test/scf.tar.gz
1.3M test
[root@localhost soft]#
说明:
实例8:显示几个文件或目录各自占用磁盘空间的大小,还统计它们的总和
命令:
du -c log30.tar.gz log31.tar.gz
输出:
[root@localhost test]# du -c log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
8 总计
[root@localhost test]#
说明:
加上-c选项后,du不仅显示两个目录各自占用磁盘空间的大小,还在最后一行统计它们的总和。
实例9:按照空间大小排序
命令:
du|sort -nr|more
输出:
[root@localhost test]# du|sort -nr|more
1288 .
608 ./test6
308 ./test4
32 ./scf
16 ./scf/service
12 ./scf/service/deploy
8 ./test3
4 ./scf/service/deploy/product
4 ./scf/service/deploy/info
4 ./scf/lib
4 ./scf/doc
4 ./scf/bin
[root@localhost test]#
说明:
实例10:输出当前目录下各个子目录所使用的空间
命令:
du -h --max-depth=1
输出:
[root@localhost test]# du -h --max-depth=1
608K ./test6
308K ./test4
32K ./scf
8.0K ./test3
1.3M .
[root@localhost test]#
每日一linux命令 du [系列]的更多相关文章
- 2018/03/08 每日一个Linux命令 之 chattr/lsattr
每日一个Linux命令 2018-03-08 Linux 命令 chattr/lsattr chattr [-参数] [+/-属性] [文件或者目录] 经过今天没有对铃,粥熬糊了,我就知道...... ...
- 2018/03/07 每日一个Linux命令 之 cat
每日一个Linux命令 2018-03-07 Linux 命令 cat cat [-参数] fileName 在之前的Linux使用中 cat 命令一直作为文本输出指令来使用,很少可以深入学习的该命令 ...
- 2018/03/11 每日一个Linux命令 之 top
每日一个Linux命令 之 top 今天在公司测试服务器上跑了一个我写的功能[本地测试过的],但是不知道怎么跑了个无限死循环出来,一个文件的体积在不停的变大,如果不管的话这能行? 上去一看,PHP ...
- 2018/03/10 每日一个Linux命令 之 find
每日一个Linux命令 2018-03-10 Linux 命令 find find [查找目录] [定义条件] 今天很累了,本来不想写了,但想到自己订的学习计划必须坚持下去,每天完成. fin ...
- 2018/03/10 每日一个Linux命令 之 cksum
每日一个Linux命令 2018-03-10 Linux 命令 cksum cksum [文件] 今天楼下的一个大妈去世了,不仅感叹,现如今,真的和以前不一样了,楼上楼下都不知道住的是谁? cksu ...
- 2018/03/09 每日一个Linux命令 之 chgrp/chown
每日一个Linux命令 2018-03-09 Linux 命令 chgrp/chown chgrp [-参数] [文件或者目录] chown [-参数] [文件所有者]:[文件所属群组] [文件或者目 ...
- 【每日一linux命令】
参考文章 1.[每日一linux命令]
- 每日一linux命令
每日一linux命令 http://www.cnblogs.com/peida/tag/每日一linux命令/
- 系列:每日一linux命令(转)
原文:http://www.cnblogs.com/peida/archive/2012/12/05/2803591.html 一. 文件目录操作命令: 1.每天一个linux命令(1):ls命令 2 ...
随机推荐
- 批处理协同blat自动发邮件
Blat - A Windows (32 & 64 bit) command line SMTP mailer. Use it to automatically eMail logs, the ...
- 利用java实现一个简单的远程监控程序
一般的远程监控软件都是用c或者c++等语言开发的,而使用java如何来实现相同的功能呢. 首先我们先介绍一下一个简单的远程监控程序的实现原理. 功能一,远程屏幕监视 (1) 必须要有监控端与被监控端, ...
- String、StringBuffer和StringBuilder——个人学习
1.首先说一下他们的名称区别: String——字符串常量,StringBuffer——字符串变量(线程安全),StringBuilder——字符串变量(非线程安全) 从名称就可以很明显的看出他们的基 ...
- 采用Json字符串,往服务器回传大量富文本数据时,需要注意的地方,最近开发时遇到的问题。
json字符串中存在常规的用户输入的字符串,和很多的富文本样式标签(用户不能直接看到,点击富文本编辑器中的html源码按钮能看到),例如下面的: <p><strong>富文本& ...
- ZooKeeper系列之八:ZooKeeper的简单操作
http://blog.csdn.net/shenlan211314/article/details/6187035 1 )使用 ls 命令来查看当前 ZooKeeper 中所包含的内容: [zk: ...
- 【POJ2699】The Maximum Number of Strong Kings(网络流)
Description A tournament can be represented by a complete graph in which each vertex denotes a playe ...
- 读书笔记-----Java并发编程实战(一)线程安全性
线程安全类:在线程安全类中封装了必要的同步机制,客户端无须进一步采取同步措施 示例:一个无状态的Servlet @ThreadSafe public class StatelessFactorizer ...
- Android入门-Service-start,end,bind,unbind之间的区别
写贴一段别人关于service中start与bind,end与unbind的分析了: Service创建有两种方法: startService或者bindService 服务不能自己运行,需要通过调 ...
- 使用 Gradle 实现 TFS 构建自动化
发布于 2014-07-16 作者 陈 忠岳 感谢微软开放技术有限公司(简称"微软开放技术")发布的构建模板,我们现在便可以在 Team Foundation Server(TFS ...
- HDOJ 2018 母牛的故事
Problem Description 有一头母牛,它每年年初生一头小母牛.每头小母牛从第四个年头开始,每年年初也生一头小母牛.请编程实现在第n年的时候,共有多少头母牛? Input 输入数据由多个测 ...