千家信息网

Linux下怎么安装并使用Dutree

发表于:2025-11-17 作者:千家信息网编辑
千家信息网最后更新 2025年11月17日,这篇文章主要介绍"Linux下怎么安装并使用Dutree"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"Linux下怎么安装并使用Dutree"文章能帮助大家解
千家信息网最后更新 2025年11月17日Linux下怎么安装并使用Dutree

这篇文章主要介绍"Linux下怎么安装并使用Dutree"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"Linux下怎么安装并使用Dutree"文章能帮助大家解决问题。

dutree是一款免费的开源,快速的命令行工具,用于分析磁盘使用情况 ,用Rust编程语言编写。 它由durep磁盘使用记者 )和 (列表目录内容,树形格式)命令行工具开发。 因此, 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"

开始安装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环境变量中:

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

现在可以使用dutree了

实例

目录深度

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

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

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

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

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

[root@localhost ~]# dutree test/

排除某个文件

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

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

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

[root@localhost ~]# dutree -H

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

进度条使用ASCII字符显示

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

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

关于"Linux下怎么安装并使用Dutree"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注行业资讯频道,小编每天都会为大家更新不同的知识点。

0