linux下磁盘分析工具,Dutree – Linux上的命令行磁盘使用情况分析工具

Dutree是一款结合了Durep和Tree功能的实用工具,用于彩色输出并分层显示文件系统。在CentOS7上安装Dutree,首先需要配置cargo的仓库地址以加快下载速度,然后使用cargo安装。安装完成后,可以通过`-d`选项限制目录深度,`-x`排除特定文件或目录,`-H`选项忽略隐藏文件。Dutree提供了方便的目录空间使用情况报告和查看功能。
摘要由CSDN通过智能技术生成

dutree的特性:

彩色输出

分层显示文件系统

用户可以聚合小文件

用户可以排除文件或目录

用户可以比较不同的目录

可靠性和速度快

系统环境

Centos7

安装

需要先安装cargo包管理器:

[root@localhost ~]# yum -y install cargo

其次配置cargo的仓库地址,因为默认使用国外源,下载速度超慢:

进入$HOME/.cargo创建config配置文件:

[root@localhost ~]# cd $HOME/.cargo [root@localhost .cargo]# touch config

将下面内容复制到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社区 [source.rustcc] registry = "git://crates.rustcc.cn/crates.io-index"

f01bf19507a5889fd394d1a436208067.png

开始安装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

88db23a18445f49c106f6134bef89823.png

看到上面最后一个warning提示,需要将/root/.cargo/bin目录添加到PATH环境变量中:

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

现在可以使用dutree了

678badb2b8be6681b80a55359b4f31b0.png

实例

目录深度

通过-d选项,加上数字,查看一层目录或者多层目录,下面是查看/root用户家目录的,查查看一层目录:

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

10d8fe1812c725aafd5d5f6d4f5541fa.png

下面是查看/root家目录最多3层目录:

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

52e6f93cc0e233b32cc379bd01831fd8.png

如果不限制目录层数,可以不加-d选项,下面查看/root/test目录:

[root@localhost ~]# dutree test/

0ae8981ae9a6645c77e31a6319dbe600.png

排除某个文件

要排除与文件或目录名称匹配的内容,请使用-x选项。下面排除test目录中包括dir1的项目:

[root@localhost ~]# dutree -x dir1 test/

f0a9f7ced4e5477323c6c5d7eeed6fa5.png

使用-H选项,可以排除隐藏文件:

[root@localhost ~]# dutree -H

10ace75c81aeeec9429b723715a40d7c.png

可以看到隐藏文件没有列出来。

进度条使用ASCII字符显示

可以使用ASCII字符#号来代替默认的进度条:

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

222f568903c29f125a0dd2ed18d55c3d.png

总结

Dutree是Durep和Tree的组合。Durep用图表创建磁盘使用情况报告,这使我们能够确定哪些目录使用了最多的空间。尽管durep可以产生类似于du的文本输出,但其真正的功能是能够将报告存储在文件中。Tree是目录显示程序,它以树状结构在终端上递归列出目录。

本文原创地址:https://www.linuxprobe.com/dutree-linux-disk.html编辑:逄增宝,审核员:逄增宝

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值