Disk space fills up quickly on Linux, and before you know it, it's time to invest in another couple of terabyte drives to house your rapidly ballooning file system. How did it ever get so bloated?

Tracking down and visualizing files and directories which are taking more than their share of the room is difficult—especially if you're a dedicated terminal dweller.

diskonaut is an app that can finally help you to visualize, identify, manage, and delete overgrown branches of your file tree, all from the comfort of your favorite terminal.

Why You Need a Disk Space Visualizer for Your Terminal

Two SSDs conncected to a Raspberry Pi 4 using USB to SATA Adapters

Despite the fact that storage is continually growing cheaper in price, hard disks and SSDs still fill up quickly, and you can easily max out your multi-terabyte SSD in a few months without even noticing.

Is it your extensive Steam library of AAA Linux games? Your collection of ultra-high resolution artistic wallpapers? Or is it a rogue backup file generated by a dockerized recipe manager which includes itself in the backup, and doubles in size every day?

The stability of your system is at risk if you don't find out and solve the problem quickly.

Sure, you can use:

        du -h
    

...to get a listing of files, directories, and their sizes, but it's time-consuming, tedious to use, and doesn't give the most readable output.

Another possibility is ncdu (Ncurses Disk Usage) which will rank your directories by size and display them in a sortable list. Lists are fine, we guess, but they don't give you the intuitive immediacy of a graphic representation.

While there are various GUI-driven disk space visualizers out there, GUI apps are bloat to the terminal native, and to be avoided at all costs.

Fortunately, if you need a disk space visualizer for your terminal, diskonaut is here to help.

How to Install diskonaut on Linux

diskonaut is written in Rust, and the easiest way to install it is with Cargo.

If you don't have Rust and Cargo already installed, entering:

        curl https://sh.rustup.rs -sSf | sh
    

...will download a script, and install it.

Now you can install diskonaut with:

        cargo install diskonaut
    

If you're using Arch Linux, diskonaut is available in the Arch User Repository (AUR):

        yay -S diskonaut
    

You can install it on Fedora with:

        sudo dnf install diskonaut
    

Alternatively, you can just download and unpack the binary, before moving it into your path using the following commands:

        wget https://github.com/imsnif/diskonaut/releases/download/0.11.0/diskonaut-0.11.0-unknown-linux-musl.tar.gz
tar -xzf diskonaut-0.11.0-unknown-linux-musl.tar.gz
sudo mv diskonaut /usr/local/bin/

Use diskonaut in Your Terminal to Find Large Files and Directories

You can either start diskonaut from within the directory you want to scan, or use the directory you want to scan as an argument:

        diskonaut /home/david/
    

After a second or so, you will notice your terminal filling with rectangles of various sizes. These represent the individual files and directories. Small files are represented by "x" and are grouped together into a separate rectangle.

diskonaut showing various rectangles with one coloured blue

Use the arrow keys to highlight each block, and hit Enter to drill down into that directory. Your terminal will repopulate with yet more blocks.

Each block (apart from the small files) is labeled with its name, the number of descendant files within it, the total disk space it occupies, and the percentage of the current directory it occupies.

You can use the + and - keys to zoom in and out, transforming those "x"s into visible objects. Escape will take you up a level, and Backspace will delete the currently highlighted object. Don't worry about doing this accidentally—diskonaut will give you a high-contrast confirmation dialog before you delete anything.

diskonaut is shockingly easy to use, very fast, and entirely keyboard driven. It's an absolute necessity in the armory of any terminal warrior.

Freeing Up Storage Space Is Only the Beginning

Once you fall into the habit of using diskonaut on a regular basis, it's easy to keep your drives efficiently vacant, and you can put off buying another SSD for another year.

But it's not just Linux storage devices that you need to declutter regularly. Take a look around the room you're in, maybe it's time to declutter your home and your life, too.