濮阳杆衣贸易有限公司

主頁 > 知識庫 > Linux磁盤管理之df命令詳細(xì)介紹和使用實例(統(tǒng)計文件或目錄的磁盤占用情況)

Linux磁盤管理之df命令詳細(xì)介紹和使用實例(統(tǒng)計文件或目錄的磁盤占用情況)

熱門標(biāo)簽:濟(jì)南智能語音電銷機器人加盟 抖音商家地圖標(biāo)注入駐店 易聯(lián)系統(tǒng)外呼營銷來回呼 河南語音電銷機器人加盟公司 如何找電銷機器人 電銷機器人怎么打卡 江西意向度高的羿智云外呼系統(tǒng) 無錫ai智能語音電銷機器人廠家 無錫真人電銷機器人供應(yīng)商

1.命令格式:

du [選項][文件]

2.命令功能:

顯示每個文件和目錄的磁盤使用空間。

3.命令參數(shù):

-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  以一開始處理時的文件系統(tǒng)為準(zhǔn),若遇上其它不同的文件系統(tǒng)目錄則略過。 

-L符號鏈接>或--dereference符號鏈接> 顯示選項中所指定符號鏈接的源文件大小。   

-S或--separate-dirs   顯示個別目錄的大小時,并不含其子目錄的大小。 

-X文件>或--exclude-from=文件>  在文件>指定目錄或文件。   

--exclude=目錄或文件>         略過指定的目錄或文件。    

-D或--dereference-args   顯示指定符號鏈接的源文件大小。   

-H或--si  與-h參數(shù)相同,但是K,M,G是以1000為換算單位。   

-l或--count-links   重復(fù)計算硬件鏈接的文件。  

4.使用實例:

實例1:顯示目錄或者文件所占空間 

命令:du

輸出:


復(fù)制代碼
代碼如下:

[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)前目錄的總大小

實例2:顯示指定文件所占空間

命令:du log2012.log

輸出:


復(fù)制代碼
代碼如下:

[root@localhost test]# du log2012.log
300 log2012.log
[root@localhost test]#

實例3:查看指定目錄的所占空間

命令:du scf

輸出:


復(fù)制代碼
代碼如下:

[root@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]#

實例4:顯示多個文件所占空間

命令:du log30.tar.gz log31.tar.gz

輸出:


復(fù)制代碼
代碼如下:

[root@localhost test]# du log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
[root@localhost test]#

實例5:只顯示總和的大小

命令:du -s

輸出:


復(fù)制代碼
代碼如下:

[root@localhost test]# du -s
1288 .
[root@localhost test]# du -s scf
32 scf
[root@localhost test]# cd ..
[root@localhost soft]# du -s test
1288 test
[root@localhost soft]#

實例6:方便閱讀的格式顯示

命令:du -h test

輸出:


復(fù)制代碼
代碼如下:

[root@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]#

實例7:文件和目錄都顯示

命令:du -ah test

輸出:


復(fù)制代碼
代碼如下:

[root@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
[root@localhost soft]#

實例8:顯示幾個文件或目錄各自占用磁盤空間的大小,還統(tǒng)計它們的總和

命令:du -c log30.tar.gz log31.tar.gz

輸出:


復(fù)制代碼
代碼如下:

[root@localhost test]# du -c log30.tar.gz log31.tar.gz
4 log30.tar.gz
4 log31.tar.gz
8 總計
[root@localhost test]#

加上-c選項后,du不僅顯示兩個目錄各自占用磁盤空間的大小,還在最后一行統(tǒng)計它們的總和。

實例9:按照空間大小排序

命令:du|sort -nr|more

輸出:


復(fù)制代碼
代碼如下:

[root@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
[root@localhost test]#

實例10:輸出當(dāng)前目錄下各個子目錄所使用的空間

命令:du -h  --max-depth=1

輸出:


復(fù)制代碼
代碼如下:

[root@localhost test]# du -h --max-depth=1
608K ./test6
308K ./test4
32K ./scf
8.0K ./test3
1.3M .
[root@localhost test]#

標(biāo)簽:濱州 常德 河源 江蘇 保山 宿州 綏化 亳州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux磁盤管理之df命令詳細(xì)介紹和使用實例(統(tǒng)計文件或目錄的磁盤占用情況)》,本文關(guān)鍵詞  Linux,磁盤,管理,之,命令,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Linux磁盤管理之df命令詳細(xì)介紹和使用實例(統(tǒng)計文件或目錄的磁盤占用情況)》相關(guān)的同類信息!
  • 本頁收集關(guān)于Linux磁盤管理之df命令詳細(xì)介紹和使用實例(統(tǒng)計文件或目錄的磁盤占用情況)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    改则县| 黑龙江省| 汕尾市| 临夏县| 明水县| 宁晋县| 天柱县| 辰溪县| 灯塔市| 英吉沙县| 织金县| 桑日县| 德安县| 浠水县| 遂川县| 五华县| 云浮市| 怀安县| 安达市| 饶平县| 盱眙县| 平定县| 宣武区| 保山市| 平利县| 当雄县| 马边| 凯里市| 股票| 成安县| 东兴市| 东港市| 溧水县| 安平县| 大姚县| 邳州市| 平邑县| 大英县| 峨眉山市| 墨玉县| 四子王旗|