新聞中心
dutree是一款免費的開源,快速的命令行工具,用于分析磁盤使用情況 ,用Rust編程語言編寫。 它由durep ( 磁盤使用記者 )和樹 (列表目錄內(nèi)容,樹形格式)命令行工具開發(fā)。 因此, dutree以樹狀格式報告磁盤使用情況,下面為大家講解一下Linux下安裝并使用Dutree具體方法。

創(chuàng)新互聯(lián)建站服務項目包括哈巴河網(wǎng)站建設(shè)、哈巴河網(wǎng)站制作、哈巴河網(wǎng)頁制作以及哈巴河網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,哈巴河網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務的客戶以成都為中心已經(jīng)輻射到哈巴河省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!
系統(tǒng)環(huán)境
Centos7
安裝
需要先安裝cargo包管理器:
[root@localhost ~]# yum -y install cargo
其次配置cargo的倉庫地址,因為默認使用國外源,下載速度超慢:
進入$HOME/.cargo創(chuàng)建config配置文件:
[root@localhost ~]# cd $HOME/.cargo
[root@localhost .cargo]# touch config
將下面內(nèi)容復制到config配置文件中:
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替換成速度比較快的鏡像源,這里使用上海交大的。
replace-with = 'sjtu'
# 清華大學
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 上海交通大學
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社區(qū)
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
開始安裝dutree吧:
[root@localhost ~]# cargo install dutree
Updating `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index` index
Downloaded dutree v0.2.16 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded 1 crate (638.0 KB) in 0.37s
Installing dutree v0.2.16
Downloaded signal-hook v0.1.16 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded terminal_size v0.1.13 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded thread_local v1.0.1 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded signal-hook-registry v1.2.2 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded unicode-width v0.1.8 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded memchr v2.3.4 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded regex-syntax v0.6.21 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded aho-corasick v0.7.14 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded regex v1.4.2 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded libc v0.2.80 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded lazy_static v1.4.0 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded getopts v0.2.21 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded unicode-segmentation v1.6.0 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)
Downloaded 13 crates (1.4 MB) in 0.43s
Compiling libc v0.2.80
Compiling memchr v2.3.4
Compiling lazy_static v1.4.0
Compiling unicode-width v0.1.8
Compiling regex-syntax v0.6.21
Compiling unicode-segmentation v1.6.0
Compiling thread_local v1.0.1
Compiling getopts v0.2.21
Compiling signal-hook-registry v1.2.2
Compiling terminal_size v0.1.13
Compiling aho-corasick v0.7.14
Compiling signal-hook v0.1.16
Compiling regex v1.4.2
Compiling dutree v0.2.16
Finished release [optimized] target(s) in 1m 35s
Installing /root/.cargo/bin/dutree
Installed package `dutree v0.2.16` (executable `dutree`)
warning: be sure to add `/root/.cargo/bin` to your PATH to be able to run the installed binaries
看到上面最后一個warning提示,需要將/root/.cargo/bin目錄添加到PATH環(huán)境變量中:
[root@localhost ~]# echo "export PATH=$PATH:/root/.cargo/bin" >> ~/.bashrc
[root@localhost ~]# source ~/.bashrc
現(xiàn)在可以使用dutree了
實例
目錄深度
通過-d選項,加上數(shù)字,查看一層目錄或者多層目錄,下面是查看/root用戶家目錄的,查查看一層目錄:
[root@localhost ~]# dutree -d1 ./
下面是查看/root家目錄最多3層目錄:
[root@localhost ~]# dutree -d3 ./
如果不限制目錄層數(shù),可以不加-d選項,下面查看/root/test目錄:
[root@localhost ~]# dutree test/
Dutree – Linux上的命令行磁盤使用情況分析工具Dutree – Linux上的命令行磁盤使用情況分析工具
排除某個文件
要排除與文件或目錄名稱匹配的內(nèi)容,請使用-x選項。下面排除test目錄中包括dir1的項目:
[root@localhost ~]# dutree -x dir1 test/
使用-H選項,可以排除隱藏文件:
[root@localhost ~]# dutree -H
可以看到隱藏文件沒有列出來。
進度條使用ASCII字符顯示
可以使用ASCII字符#號來代替默認的進度條:
[root@localhost ~]# dutree -d1 -A /root
Dutree – Linux上的命令行磁盤使用情況分析工具Dutree – Linux上的命令行磁盤使用情況分析工具
總結(jié)
Dutree是Durep和Tree的組合。Durep用圖表創(chuàng)建磁盤使用情況報告,這使我們能夠確定哪些目錄使用了最多的空間。盡管durep可以產(chǎn)生類似于du的文本輸出,但其真正的功能是能夠?qū)蟾娲鎯υ谖募?。Tree是目錄顯示程序,它以樹狀結(jié)構(gòu)在終端上遞歸列出目錄。
本文名稱:Linux下安裝并使用Dutree具體方法
標題網(wǎng)址:http://fisionsoft.com.cn/article/dhdpspp.html


咨詢
建站咨詢
