Linux上的Dutree - 命令行磁盘使用情况分析工具
Dutree是Durep和Tree的组合。
DUREP创建具有图形的磁盘使用报告,该报告允许我们识别哪些目录正在使用最多空间。
虽然DUREP可以产生类似于DU的文本输出,但其实际功率是在文件中存储报告的能力。
Tree是目录显示程序,该程序在终端上的树中递归地列出目录。
Tree是清洁和简单的程序,我们可以用来构建像目录和文件系统的结构。
Dutree是用RUST编程语言编写的,RUST是系统编程语言,令人惊讶地运行,防止SEGFAULTS,以及线程安全。
今天,将介绍如何在CentOS 7和Ubuntu 16.04上安装Dutree。
下面的教程从Git和Rust安装开始,如果我们已经完成此操作,则可以转到Dutree安装。
请注意,Fort安装必须为本教程运行。
Git安装
Ubuntu 16.04.
$sudo apt install git
CentOS 7.
$sudo yum install git
RUST安装
Ubuntu 16.04.
$sudo apt install curl $curl https://sh.rustup.rs -sSf | sh
CentOS 7.
$curl https://sh.rustup.rs -sSf | sh
Dutree安装
$git clone https://github.com/nachoparker/dutree.git
Cloning into 'dutree'... remote: Counting objects: 27, done. remote: Compressing objects: 100% (18/18), done. remote: Total 27 (delta 3), reused 27 (delta 3), pack-reused 0 Unpacking objects: 100% (27/27), done. Checking connectivity... done.
$curl https://sh.rustup.rs -sSf | sh
Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /home/administrator/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile file located at: /home/administrator/.profile You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable modify PATH variable: yes 1) Proceed with installation (default) 2) Customize installation 3) Cancel installation
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2016-03-01, rust version 1.24.1 (d3ae9a9e0 2016-02-27) info: downloading component 'rustc' 47.8 MiB/47.8 MiB (100 %) 1.7 MiB/s ETA: 0 s info: downloading component 'rust-std' 66.9 MiB/66.9 MiB (100 %) 1.0 MiB/s ETA: 0 s info: downloading component 'cargo' 4.2 MiB/ 4.2 MiB (100 %) 1.7 MiB/s ETA: 0 s info: downloading component 'rust-docs' 4.6 MiB/ 4.6 MiB (100 %) 1.8 MiB/s ETA: 0 s info: installing component 'rustc' info: installing component 'rust-std' info: installing component 'cargo' info: installing component 'rust-docs' info: default toolchain set to 'stable' stable installed - rustc 1.24.1 (d3ae9a9e0 2016-02-27) Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically. To configure your current shell run source $HOME/.cargo/env
设置RUST环境
$administrator@administrator:~/dutree$source $HOME/.cargo/env $administrator@administrator:~/dutree$rustc --version rustc 1.24.1 (d3ae9a9e0 2016-02-27) $administrator@administrator:~/dutree$cargo install
Installing dutree v0.1.0 (file:///home/administrator/dutree) Updating registry `https://github.com/rust-lang/crates.io-index` Updating git repository `https://github.com/eminence/terminal-size.git` Downloading getopts v0.2.15 Downloading regex v0.2.10 Downloading unicode-width v0.1.4 Downloading winapi v0.2.8 Downloading kernel32-sys v0.2.2 Downloading libc v0.2.39 Downloading winapi-build v0.1.1 Downloading regex-syntax v0.5.3 Downloading aho-corasick v0.6.4 Downloading utf8-ranges v1.0.0 Downloading thread_local v0.3.5 Downloading memchr v2.0.1 Downloading ucd-util v0.1.1 Downloading unreachable v1.0.0 Downloading lazy_static v1.0.0 Downloading void v1.0.2 Compiling regex v0.2.10 Compiling utf8-ranges v1.0.0 Compiling getopts v0.2.15 Compiling winapi v0.2.8 Compiling void v1.0.2 Compiling libc v0.2.39 Compiling ucd-util v0.1.1 Compiling winapi-build v0.1.1 Compiling lazy_static v1.0.0 Compiling unicode-width v0.1.4 Compiling unreachable v1.0.0 Compiling regex-syntax v0.5.3 Compiling memchr v2.0.1 Compiling kernel32-sys v0.2.2 Compiling thread_local v0.3.5 Compiling aho-corasick v0.6.4 Compiling terminal_size v0.1.7 (https://github.com/eminence/terminal-size.git#af31d2b0) Compiling dutree v0.1.0 (file:///home/administrator/dutree) Finished release [optimized] target(s) in 453.67 secs Installing /home/administrator/.cargo/bin/dutree
设置来源
源命令可用于将任何函数文件加载到当前shell脚本或者命令提示符中,
$source $HOME/.cargo/env
常规帮助选项,显示选项列表以及它执行的内容,
$dutree –-help Usage: dutree [options] <path> [<path>..] Options: -d, --depth [DEPTH] show directories up to depth N (def 1) -a, --aggr [N[KMG]] aggregate smaller than N B/KiB/MiB/GiB (def 1M) -s, --summary equivalent to -da, or -d1 -a1M -u, --usage report real disk usage instead of file size -b, --bytes print sizes in bytes -x, --exclude NAME exclude matching files or directories -H, --no-hidden exclude hidden files -A, --ascii ASCII characters only, no colors -h, --help show help -v, --version print version number
以下是使用各种选项显示使用Dutree的所有示例,
例子
深度
目录的深度是从树的根目录中的文件/目录的边缘的数量。
根目录将具有深度1.文件的高度是从目录到叶子的最长路径上的边的数量。
我们可以查看第一个目录深度,
$dutree -d1 test/
或者希望看到更多的文件深入,
$dutree -d2 test/
或者看一切,
$dutree test/
概括
要快速概述指定的目录使用选项-s。
$dutree -s test/
我们还可以使用-b选项查看文件大小以字节为单位,
$dutree -b test/
如果要查看除特定的扩展名或者文件或者目录名称的文件,则可以使用-x选项,
$dutree -x dir1 test/
在下面,我们看到DIR1被排除在树之外,
聚合
我们可以在某个目录下聚合文件或者指定某些文件大小以获得更好的可视化,
$dutree -a 100b test/
真实磁盘使用率
在下面的镜像中,我们看到,如何检查真实磁盘使用而不是文件大小。
文件的文件大小不等同于磁盘使用情况,这是使用的真实量的磁盘块。
小文件通常需要比假设更多的空间,因为只有一个小文件将存储在一个块中。
$dutree -u test/
比较
我们可以比较任意数量的不同文件夹,
ASCII字符
在我们看到的下面的镜像中,如何使用Dutree指定目录路径。
如果我们是不关心时尚颜色或者旧终端中块字符问题的人的类型,则可以以良好的旧纯QUII字符获取输出。
$dutree -A test/