简介
统计目录(或文件)所占磁盘空间的大小
命令格式
du [选项] [文件]
命令参数
-a 显示目录中个别文件的大小。 -s 统计文件和目录的总大小 -h 以K,M,G为单位,提供信息的可读性 -d 设置查看目录的深度,与--max-depth参数相同,需注意这个参数是最新版本的linux系统才加入,以前系统使用的是--max-depth= -b 以字节为单位显示文件大小 -c 显示个别目录或文件大小,同时也显示所有文件或目录的总和
du命令常见用法
显示指定文件所占空间
[root@boke local]# du test1 4 test1
查看指定目录所占空间
[root@boke local]# du nginx/ 8 nginx/conf/vhost 84 nginx/conf 4 nginx/fastcgi_temp 4 nginx/uwsgi_temp 4 nginx/scgi_temp 16 nginx/ssl 4 nginx/proxy_temp/4/01 4 nginx/proxy_temp/4/02
显示多个文件所占空间
[root@boke local]# du test1 test2 test3 4 test1 0 test2 0 test3
显示目录总和大小
[root@boke local]# du -s nginx/ 9928 nginx/
人性化显示目录大小
[root@boke local]# du -h nginx/ 8.0K nginx/conf/vhost 84K nginx/conf 4.0K nginx/fastcgi_temp 4.0K nginx/uwsgi_temp 4.0K nginx/scgi_temp 16K nginx/ssl
人性化显示当前目录总大小
[root@boke local]# du -sh nginx/ 9.7M nginx/
显示当前目录下各个子目录所使用的空间
[root@boke local]# du -h --max-depth=2 /opt/ 8.0M /opt/install/source 383M /opt/install/jdk1.8.0_201 9.7M /opt/install/nginx