dutree is a command line tool to analyze disk usage.
Features
- coloured output, according to the LS_COLORS environment variable.
- display the file system tree
- ability to aggregate small files
- ability to exclude files or directories
- ability to compare different directories
- fast, written in Rust
This tool is a mix between tree and durep, which we already used in this other post.
Installation
cargo install dutree
Usage
$ 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 will use the environment colors as configured in the variable LS_COLORS. This means that will match the colors of commands such as ls –color that you or your distro have configured.
You can see more details about this variable here.
Examples
Depth
If you just want to have a quick overview, use the -s flag.
, or you can just look at the first directory depth
, and increase detail if needed
, or just show everything
Skip directories
If you are only interested in the files in the current folder, you can have a quick view.
Aggregate
You can aggregate small files under a certain file size for better visualization.
The default is one mebibyte.
Exclude
You can exclude any number of directory or file names
Compare
You can compare any number of different folders, for instance these snapshots taken on different dates with btrfs-snp.
Disk usage
The file size of files is not actually equivalent to the disk usage, this is, the real amount of disk blocks that are used. Small files will take up more space than we might assume because only one small file will be stored in one block. See this post for a more complete explanation.
In fact, all files in disk are rounded to the block size, 4 kibibytes in this example.
Also, there are files that are sparse in modern filesystems. This means that they don’t use all the blocks that they need to, because for instance they have big sections of zeroes and the filesystem is smart enough to optimize that. Pay attention to the file_sparse in this example: it doesn’t really use 8KiB of disk blocks, but the minimum of 4KiB.
ASCII output
If you don’t care about fancy colors or you have problems with block characters in your old terminal, you can get the output in good old plain ASCII characters.
Another option is to unset the LS_COLORS variable.
Nacho when I’ve tried to install using your instructions I get
warning: be sure to add `/home/tim/.cargo/bin` to your PATH to be able to run the installed binaries
at the of installation and if I use the command dutree I get command not found. Any ideas
If you have never installed anything before with cargo, you need to add at the end of your `~/.bashrc` the following line
`export PATH=”/home/tim/.cargo/bin:$PATH”`
Then dutree will be available next time you open a bash shell
Thank you nacho
Hi Nacho. Thanks for this tool. It is awesome!!! Just what I always wanted.