Dutree – Linux上的命令行磁盘使用情况分析工具
Dutree是Durep和Tree的组合。Durep用图表创建磁盘使用情况报告,这使我们能够确定哪些目录使用了最多的空间。尽管durep可以产生类似于du的文本输出,但其真正的功能是能够将报告存储在文件中。Tree是目录显示程序,它以树状结构在终端上递归列出目录。
dutree的特性:
[*]彩色输出
[*]分层显示文件系统
[*]用户可以聚合小文件
[*]用户可以排除文件或目录
[*]用户可以比较不同的目录
[*]可靠性和速度快
系统环境
Centos7安装
需要先安装cargo包管理器:# yum -y install cargo其次配置cargo的仓库地址,因为默认使用国外源,下载速度超慢:进入$HOME/.cargo创建config配置文件:# cd $HOME/.cargo# touch config将下面内容复制到config配置文件中:registry = "https://github.com/rust-lang/crates.io-index"# 替换成速度比较快的镜像源,这里使用上海交大的。replace-with = 'sjtu'# 清华大学registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"# 上海交通大学registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"# rustcc社区registry = "git://crates.rustcc.cn/crates.io-index"https://www.linuxprobe.com/wp-content/uploads/2020/11/image1-1.png
开始安装dutree吧:# cargo install dutree Updating `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index` indexDownloaded dutree v0.2.16 (registry `https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index`)Downloaded 1 crate (638.0 KB) in 0.37sInstalling dutree v0.2.16Downloaded 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 target(s) in 1m 35sInstalling /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 binarieshttps://www.linuxprobe.com/wp-content/uploads/2020/11/image2-1.png
看到上面最后一个warning提示,需要将/root/.cargo/bin目录添加到PATH环境变量中:# echo "export PATH=$PATH:/root/.cargo/bin" >> ~/.bashrc # source ~/.bashrc 现在可以使用dutree了
https://www.linuxprobe.com/wp-content/uploads/2020/11/image3-1.png实例
目录深度
通过-d选项,加上数字,查看一层目录或者多层目录,下面是查看/root用户家目录的,查查看一层目录:# dutree -d1 ./https://www.linuxprobe.com/wp-content/uploads/2020/11/image4-1.png
下面是查看/root家目录最多3层目录:# dutree -d3 ./https://www.linuxprobe.com/wp-content/uploads/2020/11/image5-1.png
如果不限制目录层数,可以不加-d选项,下面查看/root/test目录:# dutree test/https://www.linuxprobe.com/wp-content/uploads/2020/11/image6-1.png排除某个文件
要排除与文件或目录名称匹配的内容,请使用-x选项。下面排除test目录中包括dir1的项目:# dutree -x dir1 test/https://www.linuxprobe.com/wp-content/uploads/2020/11/image7-1.png
使用-H选项,可以排除隐藏文件:# dutree -Hhttps://www.linuxprobe.com/wp-content/uploads/2020/11/image8-1.png
可以看到隐藏文件没有列出来。进度条使用ASCII字符显示
可以使用ASCII字符#号来代替默认的进度条:# dutree -d1 -A /roothttps://www.linuxprobe.com/wp-content/uploads/2020/11/image9-1.png总结
Dutree是Durep和Tree的组合。Durep用图表创建磁盘使用情况报告,这使我们能够确定哪些目录使用了最多的空间。尽管durep可以产生类似于du的文本输出,但其真正的功能是能够将报告存储在文件中。Tree是目录显示程序,它以树状结构在终端上递归列出目录。
{:6_264:}
页:
[1]