Your system’s hard disk can get full really quick if you don’t monitor it on a regular basis. We have got more digital data than we can even store on our devices. Therefore, checking disk space and usage is an important task that you should incorporate in your digital life.
On Linux, several utilities are available to check disk usage and storage including df, ncdu, and gdu. Read on to learn how you can use gdu to analyze disk usage on your Linux system, along with a brief guide on how to install it.
What Is the gdu Utility?
As mentioned above, gdu is a disk usage analyzer written in the Go programming language. Gdu stands for Go Disk Usage. While there are other tools available that perform the same task, gdu is a fast, reliable, and easy to use utility.
The only thing that makes gdu stand out of the crowd is its speed. It leverages the power of parallel processing to enhance the scanning rate of the drives. Although gdu’s performance is average while analyzing HDDs, its true power is unleashed when you work with SSDs.
The table below describes the performance rate of gdu while scanning 80GB of data on a 500GB SSD. Notice that gdu has the highest scan speed when compared with other disk usage analyzers.
|Command||Speed Without Cache||Speed With Cache|
|nnn -T d||31s||3s|
Download and Install gdu on Linux
Since gdu is not available on Linux distributions by default, you’ll have to install the package manually.
You can download gdu from its Github repository using curl.
curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
Change the permissions of gdu_linux_amd64 with the chmod command to make it an executable file.
sudo chmod +x gdu_linux_amd64
Move the file to the /usr/bin directory.
sudo mv gdu_linux_amd64 /usr/bin/gdu
Type gdu –version in the terminal to check whether the package was installed successfully. You will see an output that looks something like this.
Built time: Fri May 07 05:37:28 PM IST 2021
Built user: dundee
How to Use the gdu Command
If you run the command with no arguments, gdu will scan the current directory and display storage-related information.
To scan a particular directory, you can specify the name of the folder with the default command. To analyze the disk usage for /Desktop:
Note: Unlike the ls command in Linux, you can’t specify multiple directories with gdu. The system will display an error stating “Error: accepts at most 1 arg(s), received 2”.
Ignore Directories From the Output
If you want to ignore specific sub-directories while scanning for the parent directory, use the -i flag. The -i stands for Ignore and will discard any directory that follows the flag.
gdu /Desktop -i /Desktop/Ignore
The aforementioned command will analyze the /Desktop directory and will not show the /Desktop/Ignore sub-directory in the output. You can also pass multiple directories in the -i flag by separating them with the comma (,) character.
gdu /Desktop -i /Desktop/Ignore,/Desktop/Another-Folder
Gdu Functions and Options
Press the Question Mark (?) key to get a list of available operations.
To delete a directory or a file, highlight the entry and press D.
You can also view the content of any file with gdu. Simply highlight the file and hit the V key.
To get the output in black and white, use the -c flag with the command.
gdu -c ./Desktop
Gdu can also scan mounted disks on your Linux system. Use the -d flag with the command to display information related to mounted disks.
To prevent gdu from launching in interactive mode, use the -n flag.
gdu -n ./Desktop
Gdu Special Entry Identifiers
Notice in the output above, gdu displays a special character before the entries. Each character has a specific meaning that denotes the filetype.
Gdu uses the following characters in the output:
|!||Error while reading directory|
|.||Error while reading subdirectory|
|@||Socket or a symlink|
Monitoring Disk Space With gdu
While working on a Linux machine, it is important to do a regular audit of your system’s health, storage, applications, etc. Doing so will ensure that your computer can provide the best performance to you for a long time.
Storage is an essential component of a computer. With so much data readily available on the internet, carefully utilizing your disk space becomes a must. If you don’t have enough space on your device, you can always opt for cloud storage platforms to store your files.