VOOZH about

URL: https://www.tecmint.com/dutree-analyze-disk-usage-in-linux/

⇱ dutree - Analyze File System Disk Usage in Linux


Skip to content

dutree is a free, open-source, fast command-line tool for analyzing disk usage, written in the Rust programming language, which is developed from the combination of durep (disk usage reporter) and tree (list directory content in tree-like format) command-line tools. As a result, dutree reports disk usage in a tree-like format.

dutree displays colored output, depending on the values configured in the GNU LS_COLORS environment variable. This environment variable allows for setting the colors of files based on their extension, permissions, and file type.

dutree Features:

  • Show the file system tree.
  • Supports aggregating of small files.
  • Allows for comparing different directories.
  • Supports excluding files or directories.

How to Install dutree in Linux Systems

To install dutree in Linux distributions, you must have rust programming language installed on your system. If you don’t have Rust installed, you can use the following curl command to install it as shown.

$ sudo curl https://sh.rustup.rs -sSf | sh
👁 Install Rust in Linux
Install Rust on Linux

Once Rust is installed, you can run the following command to install dutree in Linux distributions as shown.

$ cargo install --git https://github.com/nachoparker/dutree.git
👁 Install dutree in Linux
Install dutree in Linux

After installing dutree, it uses environment colors according to the variable LS_COLORS, it has the same colors ls –color command that our distro has configured.

$ ls --color

The simplest way of running dutree is without arguments, this way it shows a filesystem tree.

$ dutree
👁 Linux Filesystem Disk Usage
Linux Filesystem Disk Usage

To display real disk usage instead of file size, use the -u flag.

$ dutree -u 
👁 Show Linux Disk Usage
Show Linux Disk Usage

Show Directories in Depth

You can show directories up to a given depth (default 1), using the -d flag. The command below will show directories up to a depth of 3, under the current working directory.

For example if the current working directory (~/), then display the size of ~/*/*/* as shown in the following sample screenshot.

$ dutree -d 3
👁 Show Directories in Depth Disk Usage
Show Directories in Depth Disk Usage

Exclude Files or Directories in Output

To exclude matching a file or directory name, use the -x flag.

$ dutree -x CentOS-7.0-1406-x86_64-DVD.iso 
👁 Show Disk Usage with Exclude Filename
Show Disk Usage with Exclude Filename

You can also get a quick local overview by skipping directories, using the -f option, like so.

$ dutree -f
👁 Quick Overview by Skipping Directories
Quick Overview by Skipping Directories

A full summary/overview can be generated using the -s flag as shown.

$ dutree -s
👁 Linux Disk Usage Summary
Linux Disk Usage Summary

Aggregate Small Files

It is possible to aggregate files smaller than a certain size, default is 1M as shown.

$ dutree -a 
👁 Aggregate Small Files
Aggregate Small Files

Exclude Hidden Files

The -H switch allows for excluding hidden files in the output.

$ dutree -H

The -b option is used to print sizes in bytes, instead of kilobytes (default).

$ dutree -b

To turn off colors, and only display ASCII characters, use the -A flag like so.

$ dutree -A

You can view the dutree help message using the -h option.

$ dutree -h

Usage: dutree [options] [..]
 
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 is a simple yet powerful command-line tool to show file size and analyze disk usage in a tree-like format, on Linux systems. Use the comment form below to share your thoughts or queries about it, with us.

If this article helped, share it with someone on your team.
TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
☕ Buy Me a Coffee
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

6 Comments

Leave a Reply
  1. The dutree last release is from 2019. Not a good sign IMHO.

    Reply
    • @Grokker,

      I agree. The fact that dutree hasn’t been updated in over 4 years is not a good sign. It means that the project is no longer being actively maintained…

      Reply
    • I prefer ncdu, which is an NCurses-based du (disk usage) viewer that provides a fast and easy-to-use interface through the famous du utility.

      It allows one to browse through the directories and show percentages of disk usage with the ncurses library.

      Reply
      • @Abubua,

        Thank you for sharing your preference. ncdu is indeed a powerful tool with its NCurses-based interface for the du utility. It’s great to know that you find its interface fast and easy to use.

        We already covered about this tool here – Ncdu a NCurses Based Disk Usage Analyzer and Tracker

        Reply
  2. Looks tempting to use on a local workstation, but for remote ssh sessions the display will not look the same. I recommend “ncdu” in that case since it is most likely already available in one of the common Linux repositories regardless of the flavor.

    Reply
    • @Etescartz

      Okay, many thanks for sharing your thoughts with us.

      Reply

Got Something to Say? Join the Discussion... Cancel reply

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Check your email for a magic link to get started.