熱搜:win11繞過硬件限制安裝 一鍵重裝Win10系統(tǒng) 最干凈的u盤啟動盤 真正純凈版的win7系統(tǒng)
時(shí)間:2014-12-30 18:02:03 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20141230/33796.html 手機(jī)查看 評論 反饋
了解過Linux命令的都知道df命令能夠查看Linux磁盤的空間,本文將通過實(shí)例來給大家詳細(xì)介紹下df命令的具體用法,以便你有個(gè)了解。
Linux du命令也是查看使用空間的,但是與df命令不同的是Linux du命令是對文件和目錄磁盤使用的空間的查看,還是和df命令有一些區(qū)別的
1.命令格式:
du [選項(xiàng)][文件]
2.命令功能:
顯示每個(gè)文件和目錄的磁盤使用空間(詳見系統(tǒng)之家查看Linux磁盤空間的八大方法)。
3.命令參數(shù):
-a或-all 顯示目錄中個(gè)別文件的大小。
-b或-bytes 顯示目錄或文件大小時(shí),以byte為單位。
-c或--total 除了顯示個(gè)別目錄或文件的大小外,同時(shí)也顯示所有目錄或文件的總和。
-k或--kilobytes 以KB(1024bytes)為單位輸出。
-m或--megabytes 以MB為單位輸出。
-s或--summarize 僅顯示總計(jì),只列出最后加總的值。
-h或--human-readable 以K,M,G為單位,提高信息的可讀性。
-x或--one-file-xystem 以一開始處理時(shí)的文件系統(tǒng)為準(zhǔn),若遇上其它不同的文件系統(tǒng)目錄則略過。
-L《符號鏈接》或--dereference《符號鏈接》 顯示選項(xiàng)中所指定符號鏈接的源文件大小。
-S或--separate-dirs 顯示個(gè)別目錄的大小時(shí),并不含其子目錄的大小。
-X《文件》或--exclude-from=《文件》 在《文件》指定目錄或文件。
--exclude=《目錄或文件》 略過指定的目錄或文件。
-D或--dereference-args 顯示指定符號鏈接的源文件大小。
-H或--si 與-h參數(shù)相同,但是K,M,G是以1000為換算單位。
-l或--count-links 重復(fù)計(jì)算硬件鏈接的文件。
4.使用實(shí)例:
實(shí)例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]#
說明:
只顯示當(dāng)前目錄下面的子目錄的目錄大小和當(dāng)前目錄的總的大小,最下面的1288為當(dāng)前目錄的總大小
實(shí)例2:顯示指定文件所占空間
命令:du log2012.log
輸出:
代碼如下:
。踨oot@localhost test]# du log2012.log
300 log2012.log
[root@localhost test]#
實(shí)例3:查看指定目錄的所占空間
命令:du scf
輸出:
代碼如下:
。踨oot@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]#
實(shí)例4:顯示多個(gè)文件所占空間
命令:du log30.tar.gz log31.tar.gz
輸出:
代碼如下:
。踨oot@localhost test]# du log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
。踨oot@localhost test]#
實(shí)例5:只顯示總和的大小
命令:du -s
輸出:
代碼如下:
。踨oot@localhost test]# du -s
1288 。
。踨oot@localhost test]# du -s scf
32 scf
。踨oot@localhost test]# cd 。。
。踨oot@localhost soft]# du -s test
1288 test
。踨oot@localhost soft]#
實(shí)例6:方便閱讀的格式顯示
命令:du -h test
輸出:
代碼如下:
。踨oot@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]#
實(shí)例7:文件和目錄都顯示
命令:du -ah test
輸出:
代碼如下:
。踨oot@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
。踨oot@localhost soft]#
實(shí)例8:顯示幾個(gè)文件或目錄各自占用磁盤空間的大小,還統(tǒng)計(jì)它們的總和
命令: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 總計(jì)
。踨oot@localhost test]#
加上-c選項(xiàng)后,du不僅顯示兩個(gè)目錄各自占用磁盤空間的大小,還在最后一行統(tǒng)計(jì)它們的總和。
實(shí)例9:按照空間大小排序
命令:du|sort -nr|more
輸出:
代碼如下:
。踨oot@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
。踨oot@localhost test]#
實(shí)例10:輸出當(dāng)前目錄下各個(gè)子目錄所使用的空間
命令:du -h --max-depth=1
輸出:
代碼如下:
。踨oot@localhost test]# du -h --max-depth=1
608K 。/test6
308K 。/test4
32K 。/scf
8.0K 。/test3
1.3M 。
。踨oot@localhost test]#
上面就是Linux使用df命令查看磁盤空間的方法介紹了,使用df命令你還可查看Linux磁盤空間是否滿了(詳見系統(tǒng)之家怎么查看Linux磁盤空間是否滿了?),你學(xué)會了嗎?
發(fā)表評論
共0條
評論就這些咯,讓大家也知道你的獨(dú)特見解
立即評論以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場