DUtree is a combination of Durep and Tree. Durep creates disk usage reports with graphs which allows us to identify which directories are using the most space. Although durep can produce text output similar to du, its real power is the ability to store reports in a file. Tree is directory displaying program that recursively list directory in tree like structure on Terminal. Tree is clean and simple program that you can use to build tree like structure for directories and file systems.This leads me to list down features of DUtree,
- Fancy - Coloured output,
- Hierarchical Display the file system,
- User can aggregate small files,
- User can exclude files or directories,
- User can compare different directories,
- Reliable & Fast.
DUTree is written in RUST programming Language, Rust is systems programming language that runs amazingly fast, prevents segfaults, and thread safe. Today, I will be showing you how to install DUTree on CentOS 7 and Ubuntu 16.04. Below tutorial starts from Installation on Git and RUST, if you already have completed this you can move to Dutree Installation. Please note, RUST Installation is must for this tutorial to run.
Git Installation
Ubuntu 16.04
$ sudo apt install git
CentOS 7
$ sudo yum install git
RUST Installation
Ubuntu 16.04
$ sudo apt install curl $ curl https://sh.rustup.rs -sSf | sh
Centos 7
$ curl https://sh.rustup.rs -sSf | sh
DUTree Installation
$ 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
$ 1
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: latest update on 2018-03-01, rust version 1.24.1 (d3ae9a9e0 2018-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 2018-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
Set RUST Environment
$ administrator@administrator:~/dutree$ source $HOME/.cargo/env $ administrator@administrator:~/dutree$ rustc --version rustc 1.24.1 (d3ae9a9e0 2018-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
Setting Source
The source command can be used to load any functions file into the current shell script or a command prompt,
$ source $HOME/.cargo/env
General Help option, shows list of options and what it performs,
$ 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
Below are all example using various options to show use of dutree,
Example
Depth
The depth of a directory is the number of edges from the file/directory to the tree's root directory. A root directory will have a depth of 1. The height of a file is the number of edges on the longest path from the directory to a leaf.
You can look at first directory depth by,
$ dutree -d1 test/
or want to see more files in depth,
$ dutree -d2 test/
or see everything,
$ dutree test/
Summary
To have quick overview for specified directory use option -s.
$ dutree -s test/
you can also see file size in bytes using -b option,
$ dutree -b test/
if you want to see files excluding specific extension or file or directory name you can use -x option,
$ dutree -x dir1 test/
below you see that dir1 is excluded from tree,
Aggregation
You can aggregate files under a certain directory or specify certain file size for better visualization,
$ dutree -a 100b test/
Real Disk Usage
In below image you see, how to check real disk usage instead of file size. The file size of files is not equivalent to the disk usage, this are the real amount of disk blocks that are used. Small files generally takes more space than we assume because only one small file will be stored in one block.
$ dutree -u test/
Compare
You can compare any number of different folders,
ASCII characters
In below image you see, How to use dutree specifying directory path. If you are type of person who don’t care about trendy colors or have problems with block characters in your old terminal, you can get the output in good old plain ASCII characters.
$ dutree -A test/
Try using LS_COLOR variable for fancy colours for your environment and let us know your comments.