Linux Commands

Analyze Disk Usage Using GDU Command Line Tool

This article will cover a guide on using the “gdu” command line utility in Linux. This tool can be used to analyze free as well used space on any storage device connected to your Linux system. Written in Go programming language, gdu claims to be fast at analyzing solid state drives. According to a benchmark provided on its GitHub repository, it can analyze an entire disk faster than other similar tools.

Main Features of Gdu

Gdu can analyze free and used space of entire disks or it can find size information about individual files and directories. It can also ignore specific directories so that they are excluded from disk usage analysis. Gdu provides a command line option where you can allot CPU cores to speed up the analysis process. Other main features of gdu include ability to produce colored output for better readability, ability to ignore hidden files and folders, an optional interactive mode, ability to analyze external drives connected to a Linux system, and ability to export findings to an external file in JSON format.

Installing Gdu in Linux

You can install gdu in Linux by downloading official Linux packages provided by developers of the app. These packages are compatible with numerous Linux distributions and hardware architectures. Universal executable binaries that work on all Linux distributions are also available. You can download these packages and binaries from the gdu releases page on GitHub. Further installation instructions are available here.

Using Gdu Command in Linux

To show size of all files and folders located in current directory, run the following command (assuming that you have downloaded executable binary for amd64 architecture):

$ ./gdu_linux_amd64

If you installed a system wide gdu package, you many need to just run the following command to get directory information:

$ gdu

Depending on your current directory, you may see some output similar to this:

In this interactive mode, you can scroll through entries using arrow keys on the keyboard as well as through the mouse wheel. You can navigate to any listed directory by hitting <Enter> key.

If you just want to get disk usage information in non-interactive mode, run the same command with “-np” switch:

$ ./gdu_linux_amd64 -np

To show information about any specific directory, supply its path to the gdu command in interactive or non-interactive mode. Here are two example commands showing usage for both modes:

$ ./gdu_linux_amd64 "$HOME/nltk_data"

$ ./gdu_linux_amd64 -np "$HOME/nltk_data"

To show the total size of a directory without listing its contents, use the “-nps” switch.

$ ./gdu_linux_amd64 -nps "$HOME/nltk_data"

To ignore hidden folders, use the “-H” command line option.

$ ./gdu_linux_amd64 -H

To ignore a specific directory or multiple folders, you can use the “-i” command line option and supply space separated absolute paths. Here is an example command:

$ ./gdu_linux_amd64 -np -i "$HOME/nltk_data/corpora/wordnet"

You can replace the directory path in above command with any other absolute path.

To show free and used space on all internal and external devices connected to your Linux system, use gdu command with “-d” command line switch:

$ ./gdu_linux_amd64 -d

Depending on configuration of your Linux system, you may see some output similar to this:

This is in interactive mode, so you can access the contents of each drive and check the sizes of individual files and folders as well. To get same information in non-interactive mode, use the following command:

$ ./gdu_linux_amd64 -npsd

To export analyzed results to a JSON file, use the “-o” command line option. Here is an example:

$ ./gdu_linux_amd64 "$HOME/nltk_data" -o info.json

You can replace the directory path in quotes with any other absolute path of your choice. You can use any filename after “-o” command line switch to export findings.

For more information about gdu and its command line options, use the following command:

$  ./gdu_linux_amd64 --help


Gdu is a fast disk usage analyzing tool that is specially optimized for solid state drives. Though it works with traditional hard drives as well, its performance improvements and analysis speed are especially noticeable on solid state drives. Its interactive mode is quite useful for finding file sizes while navigating up and down through directories.

About the author

Nitesh Kumar

I am a freelancer software developer and content writer who loves Linux, open source software and the free software community.