本文和大家分享的主要是linux中du 命令相關(guān)內(nèi)容,一起來看看吧,希望對大家學習linux有所幫助。
Linux du 命令也是查看使用空間的,但是與 df 命令不同的是linux du 命令是對 文件和目錄磁盤使用的空間的查看 ,還是和 du 命令有一些區(qū)別的.
命令格式:
du [選項][文件]
命令功能:
顯示每個文件和目錄的磁盤使用空間。
命令參數(shù):
使用實例:
顯示當前目錄或者文件所占空間
命令:
du
輸出:
4 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/flex4 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/flex-resource-production4 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/flex-resource-test4 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/gradle-resources-production4 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/gradle-resources-test4 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/gwt84 ./.IntelliJIdea14/system/compile-server/spark_test_2956500d/targets/java-production/spark_test/src-out88 ./.IntelliJIdea14/system/compiler/accessmodifier.d136518b/.caches/jasper_validator88 ./.IntelliJIdea14/system/compiler/accessmodifier.d136518b/.caches10000 c:\user\zang
......
把當前目錄下面所有的文件都列出來.
說明:
只顯示當前目錄下面的子目錄的目錄大小和當前目錄的總的大小,最下面的10000為當前目錄的總大小
顯示指定文件所占空間
命令:
du file_name
輸出:
$ du Untitled5.ipynb4 Untitled5.ipynb
查看指定目錄的所占空間
命令:
du path
輸出:
8 perl5/lib/perl5/x86_64-linux-thread-multi/auto/Devel/StackTrace12 perl5/lib/perl5/x86_64-linux-thread-multi/auto/Devel4280 perl5/lib/perl5/x86_64-linux-thread-multi/auto
......12 perl5/lib/perl5/Devel/StackTrace32 perl5/lib/perl5/Devel18632 perl5/lib/perl518636 perl5/lib112 perl5/bin30284 perl5
顯示多個文件所占空間
命令:
du file1 file2
輸出:
[root@master ~]# du anaconda-ks.cfg a.pl
4 anaconda-ks.cfg
4 a.pl[root@master ~]#
只顯示總和的大小
命令:
du -s
輸出:
[root@master ~]# du -s4110140 .
[root@master ~]#
方便閱讀的格式顯示
命令:
du -h test
輸出:
[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
文件和目錄都顯示
命令:
du -ah test
輸出:
[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
顯示幾個文件或目錄各自占用磁盤空間的大小,還統(tǒng)計它們的總和
命令:
[root@master v2.0]# du -ch sorted_hsa_1132_isopiR.sta dre_58_isopiR_delEditing_sta.sta
輸出:
[root@master v2.0]# du -ch sorted_hsa_1132_isopiR.sta dre_58_isopiR_delEditing_sta.sta
1.1G sorted_hsa_1132_isopiR.sta
718M dre_58_isopiR_delEditing_sta.sta
1.8G total
按照空間大小排序
命令:
du|sort -nr|more
輸出:
[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]#
輸出當前目錄下各個子目錄所使用的空間
命令:
du -h --max-depth=1
輸出:
[root@localhost test]# du -h --max-depth=1
608K ./test6
308K ./test4
32K ./scf
8.0K ./test3
1.3M .
[root@localhost test]#
來源:Linux公社