How to Install and Use Gdu Disk Usage Analyzer on Ubuntu 20.04

Linux has plenty of tools and commands for checking disk utilization. Some of these tools and commands come pre-installed. Take a look at the following list of commands for checking disk usage information, these can be found on many Linux distros by default:

  • df: shows usage for file system disk space.
  • du: estimates disk usage for files, directories.
  • ls -al: displays all the contents of a folder.
  • stat: shows the status of a file and file system.

Ubuntu also has a GUI-based tool called ‘Disk Usage Analyzer’ for analyzing disk usage. Likewise there is another tool ‘GDU Disk Usage Analyzer’ to view disk usage on many Linux-based distros and macOS.

GDU is written in ‘Go’ language and the official GitHub page frames it as ‘Pretty fast disk usage analyzer’ particularly for SSDs. It also works for HDDs but the performance is not as efficient as in SDD.

What will we cover

In this guide, I will show you how to install and use the GDU Disk Usage Analyzer on Ubuntu 20.04. Let’s get started with this guide.

Prerequisites

  • Internet access for fetching various files.
  • User account with ‘sudo’ access.

Installing GDU Disk Usage Analyzer on Ubuntu 20.04

Installation using an archive file

Step 1. The official GitHub page provides a download link for the archive file for GDU. To download the file, follow the command:

wget https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz


Downloading GDU

Step 2. Now extract the downloaded tar with the command:

tar xzf gdu_linux_amd64.tgz


Extracting Tar file

Step 3. Make the extracted file executable with:

sudo chmod +x gdu_linux_amd64

Step 4. Move the extracted file to the /usr/bin/ directory which contains most of the executable files:

sudo mv gdu_linux_amd64 /usr/bin/gdu

Step 5. If everything has been set up correctly, we can verify the installation, check the version of gdu with the command:

gdu --version

Making file executable and checking version

Uninstalling GDU

To uninstall GDU, we need to simply remove the GDU executable file from the directory ‘/usr/bin/’ with the command:

sudo rm /usr/bin/gdu


Uninstalling GDU

Installation using Snap repository

GDU can also be installed with Snap packages which contain all of its dependencies. Snap packages or simply Snaps can be installed from Snap Store. Snap  comes pre-shipped with many popular Linux distributions including Ubuntu 18.04 LTS (Bionic Beaver) and Ubuntu 20.04 LTS (Focal Fossa). To check, you can use the command ‘snap --version’ and verify.

Step 1. If Snap is not present on your system, you can install it using the below two commands:

sudo apt update
sudo apt install snapd

Step 2. After the above command, simply log out and log in again to update snap’s path in a correct manner.

Step 3. Now install gdu with the command:

sudo snap install gdu-disk-usage-analyzer

Snap install GDU
Step 4. To fix various settings for GDU, run the following  commands:

snap connect gdu-disk-usage-analyzer:mount-observe :mount-observe
snap connect gdu-disk-usage-analyzer:system-backup :system-backup
snap alias gdu-disk-usage-analyzer.gdu gdu

Setting GDU using Snap
That’s all for installing GDU Disk Usage Analyzer on Ubuntu 20.04.

Now that GDU is installed, let us quickly check the usage of various options it provides, just issue the ‘help’ option as argument:

gdu --help


Sample Output:

Usage:
  gdu [directory_to_scan] [flags]

Flags:
  -h, --help                          help for gdu
  -i, --ignore-dirs strings           Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run])
  -I, --ignore-dirs-pattern strings   Absolute path patterns to ignore (separated by comma)
  -l, --log-file string               Path to a logfile (default "/dev/null")
  -m, --max-cores int                 Set max cores that GDU will use. 3 cores available (default 3)
  -c, --no-color                      Do not use colorized output
  -x, --no-cross                      Do not cross filesystem boundaries
  -H, --no-hidden                     Ignore hidden directories (beginning with dot)
  -p, --no-progress                   Do not show progress in non-interactive mode
  -n, --non-interactive               Do not run in interactive mode
  -a, --show-apparent-size            Show apparent size
  -d, --show-disks                    Show all mounted disks
  -v, --version                       Print version

GDU help option

Using GDU Disk Usage Analyzer

1. When no argument (command line option) is used, GDU will scan the current directory you are working on. For e.g. if we run this command on the home directory terminal, the following results are obtained:

GDU without any argument
2. In case if this  command is to be run on some other folder, specify the path for that folder with the command:

$ gdu /home/howtoforge/Downloads

GDU with path of a directory
3. To navigate between different directories, the GDU interface uses arrow keys. For e.g., to go inside the ‘Download’ directory use the forward arrow and to return back to it, press the back arrow.

4. To view, how much disk is utilized and amount of free space is available for all the mounted disks, we can use the command:

gdu -d

GDU showing utilization for mounted disks
In the above picture, we can see the details of the mounted disks.

5. To display the apparent size only, use:

gdu -a

GDU with apparent size only
6. To set the color scheme to white/gray/black, run:

gdu -c /path/to/folder

GDU color scheme change
7. While running GDU, several flags may appear before the name of files and directories. These flags have special meaning as shown below:

  • ‘!’ :  indicates an error during a read operation for a directory.
  • ‘.’ : indicates an error during a read operation for a subdirectory.
  • ‘@’ : Shows that the file is a symlink or a socket.
  • ‘H’ : Indicates that the same file was already counted (hard link).
  • ‘e’ : Indicates that the Directory is vacant.

Conclusion

A day-to-day task for system admin includes monitoring disk space usage. This helps in deciding whether sufficient space is available for running and installing an application, checking space for system backup, deleting redundant files etc. GDU is a very simple to use but efficient application to monitor disk space.

Share this page:

1 Comment(s)