du
命令用以查看文件和目錄的大小。能夠方便地查看每一個文件和目錄所佔用的空間。nginx
du [options][file]
複製代碼
可以使用的options值能夠經過 man df
命令查閱,這裏再也不贅述。bash
顯示目錄或者文件所佔空間:ui
du /opt/log/*
複製代碼
咱們能夠看到log目錄下全部的文件大小:spa
20 /opt/log/project/houtai/pc/suyun/log4js/2018-09-28
12 /opt/log/project/houtai/pc/suyun/log4js/2018-06-28
12 /opt/log/project/houtai/pc/suyun/log4js/2018-08-26
16 /opt/log/project/houtai/pc/suyun/log4js/2018-10-27
12 /opt/log/project/houtai/pc/suyun/log4js/2018-07-01
16 /opt/log/project/houtai/pc/suyun/log4js/2018-08-23
20 /opt/log/project/houtai/pc/suyun/log4js/2018-10-22
複製代碼
經過使用-h
讓輸出的文件大小可讀性更好一些:code
du -h /opt/log/*
複製代碼
能夠看到文件大小添加了單位K:io
20 /opt/log/project/houtai/pc/suyun/log4js/2018-09-28
12 /opt/log/project/houtai/pc/suyun/log4js/2018-06-28
12 /opt/log/project/houtai/pc/suyun/log4js/2018-08-26
16 /opt/log/project/houtai/pc/suyun/log4js/2018-10-27
12 /opt/log/project/houtai/pc/suyun/log4js/2018-07-01
16 /opt/log/project/houtai/pc/suyun/log4js/2018-08-23
20 /opt/log/project/houtai/pc/suyun/log4js/2018-10-22
複製代碼
只展現總計大小:class
du -sh /opt/log/*
複製代碼
只統計了log目錄下子目錄的大小,而沒有細化到具體的文件。file
0 /opt/log/:
12G /opt/log/banjia
4.0K /opt/log/driver-manage
2.1G /opt/log/fe-sy-banjia
8.7G /opt/log/fe-sy-lahuo
539M /opt/log/lahuo
32K /opt/log/lahuo-work
16G /opt/log/nginx
157G /opt/log/project
248K /opt/log/sale-manage
100K /opt/log/youpei
複製代碼