There are two popular ways to check disk usage in Linux terminal: du command and df command.
The du command is more for checking the space used by a directory and the df command gives you the disk utilization on filesystem level.
The gdu tool sorts of combined the functionality of both.
You can use it to check the size of directories as well as disk utilization. The built in sorting feature makes it easier to use as you don't need to combine the sort command here.
Gdu: Disk usage checking in Linux terminal
Gdu is a tool written in Go (hence the βgβ in gdu). Gdu developer has benchmark tests to show that it is quite fast for disk usage checking, specifically on SSDs. In fact, gdu is intended primarily for SSDs though it can work for HDD as well.
If you use the gdu command without any options, it shows the disk usage for the current directory you are in.
Since it has a terminal user interface (TUI), you can navigate through directories and disk using arrows. You can also sort the result by file names or size.
Hereβs how to do that:
- Use the Up arrow or k to move the cursor up. Similarly, use the down arrow or j to move the cursor down
- Enter to select directory / device
- Left arrow or h to go to parent directory
- Use d to delete the selected file or directory
- Use n to sort by name and use s to sort by size.
- Use c to sort by items
Youβll notice some symbols before some file entries. Those have specific meaning.
!
means an error occurred while reading the directory..
means an error occurred while reading a subdirectory, size may not be correct.@
means file is a symlink or socket.H
means the file was already counted (hard link).e
means directory is empty.
To see the disk utilization and free space for all mounted disks, use the option d
:
gdu -d
It shows all the details in one screen:
Sounds like a handy tool, right?
More Gdu options for Disk Usage Analysis
Here are some more options, that you can use with Gdu.
Command | Usage |
---|---|
gdu -H | Ignore Hidden Directories |
gdu -i /sys,/proc / | Ignore the specified directories and do gdu on root dorectory |
gdu -d | Show all mounted disks |
gdu -n | Run in a non-interactive mode |
Installing gdu on Linux
Interested in trying gdu. Here are a few ways of installing it.
From Official Repositories
Gdu is available in the repositories of Ubuntu, Debian, Arch Linux etc. In Debian/Ubuntu, you can install it using the apt command.
So, open a terminal and run:
sudo apt update
sudo apt install gdu
If you are an Arch Linux user, you can install it using the pacman command.
sudo pacman -Syu gdu
Alternatively, install gdu using the official binary
Gdu provides a binary, which you can download and use. First, make sure you have curl installed.
sudo apt install curl
Then, download the file and extract it using the commands below:
curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
Now, give it execution permission and move the binary file somewhere that is in the path. You can do it by:
chmod +x gdu_linux_amd64
mv gdu_linux_amd64 /usr/bin/gdu
Wrapping Up
There are more friendly ways to see the disk usage in Linux with graphical tools like GNOME Disks. If you are confined to the terminal, you can use a TUI tool like ncdu to get the disk usage information with a sort of graphical touch. Gdu is one such entry to this list.
Gdu is a neat tool, that does not come with overwhelming options. It provides some necessary functions with speed in mind. It's something you can add to your toolbox.