dutree is a command line tool to analyze disk usage.
- 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.
cargo install dutree
$ dutree --help
Usage: dutree [options] <path> [<path>..]
-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.
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
If you are only interested in the files in the current folder, you can have a quick view.
You can aggregate small files under a certain file size for better visualization.
The default is one mebibyte.
You can exclude any number of directory or file names
You can compare any number of different folders, for instance these snapshots taken on different dates with btrfs-snp.
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.
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.
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.