With new uses for computers being discovered every day, disk usage has grown exponentially. Where 40GBs of HDD storage used to suffice for personal computing, now even terabytes of disk storage fail to do the job. All the resources and cache files have started taking up more storage space to perform more functions, and with that, it has brought forth the need for smarter disk utilization. Unlike Windows, Ubuntu 20.04 comes with multiple built-in options to help you with that. Let’s explore those in order to help you start with effective and efficient disc usage management.
Below you’ll find some of the commands to help you manage your disc usage through your terminal:
You can “df” to show the consumption for file system usage.
“du” will tell you the estimated usage by files and directories.
Typing “ls -al” will tell you about all the contents of the folder.
With “stat” you can find the status of a file/folder and the file system.
Installing the GDU Disk Usage Analyzer through the terminal
Along with many other Linux distros, Ubuntu also has a very user-friendly tool called “GDU Disk Usage Analyzer”. Written in “Golang”, the official documentation claims it to be a considerably fast tool, specifically if you have an SSD. It works pretty good with HDDs as well, but the performance isn’t nearly comparable to that when analyzing SSDs.
In order to get started with the installation, you can target the official GitHub page for a download link. You can run this to start the download:
$ wget https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz
Once the archive has been completely downloaded, you need to extract it using the following command:
$ tar xzf gdu_linux_amd64.tgz
Executing this command will not produce any output, in order to check the results, you can use “ls -al” to see the output.
Note: the listing highlighted green is the extracted file.
Following that, you’ll be required to convert the extracted file into an executable in order to install the disk usage analyzer. You can do so through this:
$ sudo chmod +x gdu_linux_amd64
Following this execution, you’ll need to move this executable into the directory known as “/usr/bin/” through the “mv” command, like the following:
$ sudo mv gdu_linux_amd64 /usr/bin/gdu
With this move, GDU is officially installed on your Ubuntu 20.04 computer.
You can verify the install with this:
$ gdu –version
Using the GDU Disk Usage Analyzer
To start the tool, you can simply type:
Running this will update the terminal view to this:
You can either use the arrows to navigate the folders in the directory and get the stats, or you could open up GDU directly in any folder. You can specify the path like following:
$ gdu /home/hadi/HelloWorld
Executing this will open up the tool in your desired folder.
You can use the following to know exactly how much disk space has been consumed and how much is available on all of the mounted disks:
$ gdu -d
For the apparent size of your directories, you can use:
$ gdu -a
While running the GDU Disk Analyzer, you may come across some flags before the names of your files and directories. Their meaning is as follows:
- ‘H’ means that the same file has already been counted.
- ‘@’ means that the file is a socket or a symlink.
- ‘.’ means that there was an error during the read operation for a sub-directory.
- ‘!’ means that there was an error during the read operation for a file or a directory.
- ‘e’ means that the directory is empty.
Unlike the installation process, uninstallation is a fairly simple process. All you have to do is remove the executable you placed in the bin directory. You can complete this uninstall by typing:
$ sudo rm /usr/bin/gdu
Running this will not produce any output. You can run the “gdu” command to ensure that the file has been successfully removed.
Keeping an eye on disk usage is a critical duty for system admins. It helps them decide whether enough space is available on the server for efficiently and effectively installing and running the required applications, creating a backup image of the system, and hence deleting the redundant files amongst many others. If you are using Ubuntu 20.04 or any other Linux-based OS for your server, now you can utilize GDU to keep an eye on the disk consumption without much hassle.