Introduction
The gdu tool is created for SSD drives where parallel processing can be utilized. This tool can also work with HDD with less performance compared to SSD drives. You can also check benchmark results. There are many other similar tools and you have to play with gdu first to see if satisfy your needs.
How to Install Gdu [Linux Disk Usage Analyzer]
There are few different ways to install gdu in different Linux flavors but I am going to stick with a common way that can_be followed irrespective of what distribution you are running with.
Go to the gdu GitHub release page to download the archive file. The latest version is V5.1.0 and I suggest downloading the latest version.
Install Gdu
Go to the gdu GitHub release page to download the archive file. Currently the latest version is V5.1.0
curl -L https://github.com/dundee/gdu/releases/download/v5.1.0/gdu_linux_amd64.tgz | tar xz
By the way I suggest downloading the latest version with this command :
curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
chmod +x gdu_linux_amd64
sudo mv gdu_linux_amd64 /usr/bin/gdu
Let’s verify the installation with the version command:
gdu --version
To check the help options.
$ gdu --help
If you run the gdu command without passing any argument it will scan your current working directory which is the /root.
gdu
To scan for any particular directories you have to pass the directory name as an argument.
gdu /home/unixcop/
You cannot pass more than one argument.
gdu /home /etc
With the gdu command. Press ?
to access help.
From the help you can see, there are options to sort, scan and move across directories. Access help and try exploring all the options to get comfortable.
You can delete a file or directory by pressing the “d"
key. It will prompt you for confirmation.
You can also view the content of any file by pressing the “v"
key. To come out of the file press the escape key.
You can ignore certain directories from the output by adding directory names as an argument to the -i
flag. Multiple directories can also be passed to the -i
flag and each directory should be separated by commas.
$ gdu /home/unixcop/ -i /home/unixcop/.ssh,/home/
You may see special characters in the files and directories and each has a special meaning. From the below example you can see the “/bash” directory is empty so the character “e” is prefixed to denote that.
[ ! ] means Error while reading directory [ . ] means Error while reading subdirectory. [ @ ] means File is socket or simlink. [ H ] means Hardlink which is already counted. [ e ] means Empty directory.
If you like black and white output, you can use “-c"
flag. See the below image where the output printed in black and white.
gdu -c /etc/systemd
All the commands till now will launch an interactive mode to show disk stats. If you want the output in non-interactive mode use the “-n"
flag.
gdu -n ~