linux 硬盘路径命令行,Dutree –Linux上磁盘使用情况分析的免费开源命令行工具

原标题:Dutree –Linux上磁盘使用情况分析的免费开源命令行工具

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

b433a6283317670e296e550e613058c2.png

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"

a5c177e8b2416361ed392136f2ab1c6a.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 1crate ( 638.0KB) 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 13crates ( 1.4MB) 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

f9e252214d30182287260c04923c1f05.png

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

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

[root @localhost~]# source ~/.bashrc

现在可以使用dutree了

ab256902f2a56e13d3e84fb4f8d6da47.png

举例

目录深度

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

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

b6f072949c0b6c5194daa40a41ad5d7f.png

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

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

4cdbc9568d5455bdd1a52d9a7a6c6a18.png

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

[root @localhost~]# dutree test/

0a518df2f71a250cd3b724713b3be7b4.png

排除某个文件

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

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

84c1cbcb5424b364a2400584fc9b7c3f.png

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

[root @localhost~]# dutree -H

bc5cce8acb73ccc9c40c799c2678610b.png

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

进度条使用ASCII字符显示

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

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

e8aafc888a9059e359a1843e85eaa5a7.png

责任编辑:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值