每天一個linux命令(34):du命令 相關連結:每天一個linux命令(1):ls命令http://www.bkjia.com/os/201210/163049.html;每天一個linux命令(2):cd命令http://www.bkjia.com/os/201210/163050.html;每天一個linux命令(3):pwd命令http://www.bkjia.com/os/201210/163462.html;每天一個linux命令(4):mkdir命令http://www.bkjia.com/os/201210/163463.html;每天一個linux命令(5):rm命令http://www.bkjia.com/os/201210/163662.html;每天一個linux命令(6):rmdir命令http://www.bkjia.com/os/201210/164017.html;每天一個linux命令(7):mv命令http://www.bkjia.com/os/201210/164247.html;每天一個linux命令(8):cp命令http://www.bkjia.com/os/201210/164254.html;每天一個linux命令(9):touch命令http://www.bkjia.com/os/201211/165699.html;每天一個linux命令(10):cat命令http://www.bkjia.com/os/201211/165989.html;每天一個linux命令(11):nl命令http://www.bkjia.com/os/201211/165990.html每天一個linux命令(12):more命令http://www.bkjia.com/os/201211/165994.html每天一個linux命令(13):less命令http://www.bkjia.com/os/201211/165998.html每天一個linux命令(14):head命令http://www.bkjia.com/os/201211/166191.html每天一個linux命令(15):tail命令http://www.bkjia.com/os/201211/168702.html每天一個linux命令(16):which命令http://www.bkjia.com/os/201211/168890.html每天一個linux命令(17):whereis命令http://www.bkjia.com/os/201211/168893.html每天一個linux命令(18):locate命令http://www.bkjia.com/os/201211/168895.html每天一個linux命令(19):find命令概覽http://www.bkjia.com/os/201211/168897.html每天一個linux命令(20):find命令之exechttp://www.bkjia.com/os/201211/168901.html每天一個linux命令(21):find命令之xargshttp://www.bkjia.com/os/201211/168903.html每天一個linux命令(22):find命令的參數詳解http://www.bkjia.com/os/201211/168912.html每天一個linux命令(23):Linux目錄結構http://www.bkjia.com/os/201211/170430.html每天一個linux命令(24):Linux檔案類型與副檔名http://www.bkjia.com/os/201211/170431.html每天一個linux命令(25):linux檔案屬性詳解http://www.bkjia.com/os/201211/170434.html每天一個linux命令(26):用SecureCRT來上傳和下載檔案http://www.bkjia.com/os/201211/172022.html每天一個linux命令(27):linux chmod命令http://www.bkjia.com/os/201211/172028.html每天一個linux命令(28):tar命令http://www.bkjia.com/os/201212/172641.html每天一個linux命令(29):chgrp命令http://www.bkjia.com/os/201212/172983.html每天一個linux命令(30):chown命令http://www.bkjia.com/os/201212/173239.html每天一個linux命令(31):/etc/group檔案詳解http://www.bkjia.com/os/201212/174429.html每天一個linux命令(32):gzip命令http://www.bkjia.com/os/201212/174431.html每天一個linux命令(33):df命令http://www.bkjia.com/os/201212/174434.html Linux du命令也是查看使用空間的,但是與df命令不同的是Linux du命令是對檔案和目錄磁碟使用的空間的查看,還是和df命令有一些區別的.1.命令格式: www.2cto.com 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 以一開始處理時的檔案系統為準,若遇上其它不同的檔案系統目錄則略過。 www.2cto.com -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]# du608 ./test6308 ./test44 ./scf/lib4 ./scf/service/deploy/product4 ./scf/service/deploy/info12 ./scf/service/deploy16 ./scf/service4 ./scf/doc4 ./scf/bin32 ./scf8 ./test31288 .[root@localhost test]#說明:只顯示目前的目錄下面的子目錄的目錄大小和目前的目錄的總的大小,最下面的1288為目前的目錄的總大小執行個體2:顯示指定檔案所佔空間命令:du log2012.log輸出:[root@localhost test]# du log2012.log 300 log2012.log[root@localhost test]#說明: www.2cto.com 執行個體3:查看指定目錄的所佔空間命令:du scf輸出:[root@localhost test]# du scf4 scf/lib4 scf/service/deploy/product4 scf/service/deploy/info12 scf/service/deploy16 scf/service4 scf/doc4 scf/bin32 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.gz4 log31.tar.gz[root@localhost test]#說明:執行個體5:只顯示總和的大小命令:du -s輸出:[root@localhost test]# du -s1288 .[root@localhost test]# du -s scf32 scf[root@localhost test]# cd ..[root@localhost soft]# du -s test1288 test[root@localhost soft]#說明:執行個體6:方便閱讀的格式顯示命令:du -h test輸出:[root@localhost soft]# 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[root@localhost soft]#說明:執行個體7:檔案和目錄都顯示命令:輸出:[root@localhost soft]# 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[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.gz4 log31.tar.gz8 總計[root@localhost test]#說明:加上-c選項後,du不僅顯示兩個目錄各自佔用磁碟空間的大小,還在最後一行統計它們的總和。執行個體9:按照空間大小排序命令:du|sort -nr|more輸出:[root@localhost test]# 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[root@localhost test]#說明:執行個體10:輸出目前的目錄下各個子目錄所使用的空間命令:du -h --max-depth=1輸出:[root@localhost test]# du -h --max-depth=1608K ./test6308K ./test432K ./scf8.0K ./test31.3M .[root@localhost test]#