新聞中心
Dutree是Durep和Tree的組合。Durep用圖表創(chuàng)建磁盤使用情況報(bào)告,這使我們能夠確定哪些目錄使用了最多的空間。盡管durep可以產(chǎn)生類似于du的文本輸出,但其真正的功能是能夠?qū)?bào)告存儲(chǔ)在文件中。Tree是目錄顯示程序,它以樹狀結(jié)構(gòu)在終端上遞歸列出目錄。

成都創(chuàng)新互聯(lián)公司2013年開(kāi)創(chuàng)至今,先為民勤等服務(wù)建站,民勤等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為民勤企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
系統(tǒng)環(huán)境
Centos7
安裝
需要先安裝cargo包管理器:
[root@localhost ~]# yum -y install cargo
其次配置cargo的倉(cāng)庫(kù)地址,因?yàn)槟J(rèn)使用國(guó)外源,下載速度超慢:
進(jìn)入$HOME/.cargo創(chuàng)建config配置文件:
[root@localhost ~]# cd $HOME/.cargo
[root@localhost .cargo]# touch config
將下面內(nèi)容復(fù)制到config配置文件中:
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替換成速度比較快的鏡像源,這里使用上海交大的。
replace-with = 'sjtu'
# 清華大學(xué)
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 上海交通大學(xué)
[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"
開(kāi)始安裝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
看到上面最后一個(gè)warning提示,需要將/root/.cargo/bin目錄添加到PATH環(huán)境變量中:
[root@localhost ~]# echo "export PATH=$PATH:/root/.cargo/bin" >> ~/.bashrc
[root@localhost ~]# source ~/.bashrc
現(xiàn)在可以使用dutree了
實(shí)例
目錄深度
通過(guò)-d選項(xiàng),加上數(shù)字,查看一層目錄或者多層目錄,下面是查看/root用戶家目錄的,查查看一層目錄:
[root@localhost ~]# dutree -d1 ./
下面是查看/root家目錄最多3層目錄:
[root@localhost ~]# dutree -d3 ./
如果不限制目錄層數(shù),可以不加-d選項(xiàng),下面查看/root/test目錄:
[root@localhost ~]# dutree test/
排除某個(gè)文件
要排除與文件或目錄名稱匹配的內(nèi)容,請(qǐng)使用-x選項(xiàng)。下面排除test目錄中包括dir1的項(xiàng)目:
[root@localhost ~]# dutree -x dir1 test/
使用-H選項(xiàng),可以排除隱藏文件:
[root@localhost ~]# dutree -H
可以看到隱藏文件沒(méi)有列出來(lái)。
進(jìn)度條使用ASCII字符顯示
可以使用ASCII字符#號(hào)來(lái)代替默認(rèn)的進(jìn)度條:
[root@localhost ~]# dutree -d1 -A /root
總結(jié)
Dutree是Durep和Tree的組合。Durep用圖表創(chuàng)建磁盤使用情況報(bào)告,這使我們能夠確定哪些目錄使用了最多的空間。盡管durep可以產(chǎn)生類似于du的文本輸出,但其真正的功能是能夠?qū)?bào)告存儲(chǔ)在文件中。Tree是目錄顯示程序,它以樹狀結(jié)構(gòu)在終端上遞歸列出目錄。
網(wǎng)站名稱:Linux中使用Dutree分析磁盤使用情況
本文網(wǎng)址:http://m.fisionsoft.com.cn/article/ccdeheh.html


咨詢
建站咨詢
