每天一個Linux 命令 - du

du

  • du
    顯示當(dāng)前目錄的所有文件以及所有子目錄的文件大小
cc@MyLinux:~/vundle$ du
8   ./test/files
20  ./test
8   ./.git/refs/heads
4   ./.git/refs/tags
8   ./.git/refs/remotes/origin
12  ./.git/refs/remotes
28  ./.git/refs
8   ./.git/info
4   ./.git/branches
44  ./.git/hooks
8   ./.git/logs/refs/heads
8   ./.git/logs/refs/remotes/origin
12  ./.git/logs/refs/remotes
24  ./.git/logs/refs
32  ./.git/logs
4   ./.git/objects/info
1020    ./.git/objects/pack
1028    ./.git/objects
1168    ./.git
8   ./syntax
48  ./autoload/vundle
56  ./autoload
8   ./ftplugin
20  ./doc
1328    .
  • du -h
    以人類的角度直觀的顯示當(dāng)前目錄或指定目錄/文件的大小
cc@MyLinux:~/vundle$ du -h
8.0K    ./test/files
20K ./test
8.0K    ./.git/refs/heads
4.0K    ./.git/refs/tags
8.0K    ./.git/refs/remotes/origin
12K ./.git/refs/remotes
28K ./.git/refs
8.0K    ./.git/info
4.0K    ./.git/branches
44K ./.git/hooks
8.0K    ./.git/logs/refs/heads
8.0K    ./.git/logs/refs/remotes/origin
12K ./.git/logs/refs/remotes
24K ./.git/logs/refs
32K ./.git/logs
4.0K    ./.git/objects/info
1020K   ./.git/objects/pack
1.1M    ./.git/objects
1.2M    ./.git
8.0K    ./syntax
48K ./autoload/vundle
56K ./autoload
8.0K    ./ftplugin
20K ./doc
1.3M    .
  • du -s
    顯示文件目錄總共大小(不分別顯示子目錄)
cc@MyLinux:~/vundle$ du -s
1328    .
  • du -sh
    以人類的角度直觀的顯示文件目錄總共的大小
cc@MyLinux:~/vundle$ du -sh
1.3M    .

-du -hc file1 file2 file3 dir1
顯示多個文件和目錄的總?cè)萘浚ㄕ归_目錄顯示)

[cc@hadoop01 nginx-1.8.1]$ du -hc auto CHANGES conf LICENSE 
32K auto/os
20K auto/lib/openssl
8.0K    auto/lib/google-perftools
24K auto/lib/sha1
8.0K    auto/lib/libgd
12K auto/lib/libatomic
24K auto/lib/zlib
8.0K    auto/lib/geoip
8.0K    auto/lib/libxslt
24K auto/lib/md5
28K auto/lib/pcre
12K auto/lib/perl
192K    auto/lib
20K auto/types
52K auto/cc
448K    auto
248K    CHANGES
40K conf
4.0K    LICENSE
740K    總用量

-du -shc *
顯示當(dāng)前目錄下的文件和子目錄(不展開子目錄)的大小,并以人類直觀的方式展現(xiàn)

[cc@hadoop01 nginx-1.8.1]$ du -shc *
448K    auto
248K    CHANGES
376K    CHANGES.ru
40K conf
4.0K    configure
100K    contrib
12K html
4.0K    LICENSE
4.0K    Makefile
12K man
124K    objs
4.0K    README
4.4M    src
5.8M    總用量

總結(jié):

du 常用參數(shù) -s -c -h 并且可以組合使用

-h, --human-readable    print sizes in human readable format(e.g., 1K 234M 2G)  
-c, --total   produce a grand total

其他具體參數(shù)請查看man手冊

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容