1. 程式人生 > 其它 >Dutree – Linux上的命令列磁碟使用情況分析工具

Dutree – Linux上的命令列磁碟使用情況分析工具

Dutree是Durep和Tree的組合。Durep用圖表建立磁碟使用情況報告,這使我們能夠確定哪些目錄使用了最多的空間。儘管durep可以產生類似於du的文字輸出,但其真正的功能是能夠將報告儲存在檔案中。Tree是目錄顯示程式,它以樹狀結構在終端上遞迴列出目錄。

dutree的特性:

  • 彩色輸出
  • 分層顯示檔案系統
  • 使用者可以聚合小檔案
  • 使用者可以排除檔案或目錄
  • 使用者可以比較不同的目錄
  • 可靠性和速度快
系統環境

7

安裝

需要先安裝cargo包管理器:

[root@localhost~]#yum-yinstallcargo

其次配置cargo的倉庫地址,因為預設使用國外源,下載速度超慢:

進入$HOME/.cargo建立config配置檔案:

[root@localhost~]#cd$HOME/.cargo
[[email protected]]#touchconfig

將下面內容複製到config配置檔案中:

[source.crates-io]
registry="
#替換成速度比較快的映象源,這裡使用上海交大的。
replace-with='sjtu'
#清華大學
[source.tuna]
registry="
#上海交通大學
[source.sjtu]
registry="
#rustcc社群
[source.rustcc]
registry="git://crates.rustcc.cn/crates.io-index"


開始安裝dutree吧:

[root@localhost~]#cargoinstalldutree
Updating``index
Downloadeddutreev0.2.16(registry``)
Downloaded1crate(638.0KB)in0.37s
Installingdutreev0.2.16
Downloadedsignal-hookv0.1.16(registry``)
Downloadedterminal_sizev0.1.13(registry``)
Downloadedthread_localv1.0.1(registry``)
Downloadedsignal-hook-registryv1.2.2(registry``)
Downloadedunicode-widthv0.1.8(registry``)
Downloadedmemchrv2.3.4(registry``)
Downloadedregex-syntaxv0.6.21(registry``)
Downloadedaho-corasickv0.7.14(registry``)
Downloadedregexv1.4.2(registry``)
Downloadedlibcv0.2.80(registry``)
Downloadedlazy_staticv1.4.0(registry``)
Downloadedgetoptsv0.2.21(registry``)
Downloadedunicode-segmentationv1.6.0(registry``)
Downloaded13crates(1.4MB)in0.43s
Compilinglibcv0.2.80
Compilingmemchrv2.3.4
Compilinglazy_staticv1.4.0
Compilingunicode-widthv0.1.8
Compilingregex-syntaxv0.6.21
Compilingunicode-segmentationv1.6.0
Compilingthread_localv1.0.1
Compilinggetoptsv0.2.21
Compilingsignal-hook-registryv1.2.2
Compilingterminal_sizev0.1.13
Compilingaho-corasickv0.7.14
Compilingsignal-hookv0.1.16
Compilingregexv1.4.2
Compilingdutreev0.2.16
Finishedrelease[optimized]target(s)in1m35s
Installing/root/.cargo/bin/dutree
Installedpackage`dutreev0.2.16`(executable`dutree`)
warning:besuretoadd`/root/.cargo/bin`toyourPATHtobeabletoruntheinstalledbinaries


看到上面最後一個warning提示,需要將/root/.cargo/bin目錄新增到PATH環境變數中:

[root@localhost~]#echo"exportPATH=$PATH:/root/.cargo/bin">>~/.bashrc
[root@localhost~]#source~/.bashrc

現在可以使用dutree了

例項 目錄深度

通過-d選項,加上數字,檢視一層目錄或者多層目錄,下面是檢視/root使用者家目錄的,查檢視一層目錄:

[root@localhost~]#dutree-d1./


下面是檢視/root家目錄最多3層目錄:

[root@localhost~]#dutree-d3./


如果不限制目錄層數,可以不加-d選項,下面檢視/root/test目錄:

[root@localhost~]#dutreetest/
排除某個檔案

要排除與檔案或目錄名稱匹配的內容,請使用-x選項。下面排除test目錄中包括dir1的專案:

[root@localhost~]#dutree-xdir1test/


使用-H選項,可以排除隱藏檔案:

[root@localhost~]#dutree-H


可以看到隱藏檔案沒有列出來。

進度條使用ASCII字元顯示

可以使用ASCII字元#號來代替預設的進度條:

[root@localhost~]#dutree-d1-A/root
總結

Dutree是Durep和Tree的組合。Durep用圖表建立磁碟使用情況報告,這使我們能夠確定哪些目錄使用了最多的空間。儘管durep可以產生類似於du的文字輸出,但其真正的功能是能夠將報告儲存在檔案中。Tree是目錄顯示程式,它以樹狀結構在終端上遞迴列出目錄。