The easiest way to check the disk space is to use the df command:
And if you are curious, the
-H option with the df command is used to get output in human-readable form.
You can clearly see, it gave me all the necessary details like the size of the disk, used space, available space, and mounting point.
Want to know more methods of checking disk space? Here you have it.
Check disk space in the Ubuntu command line
Rather than nuking the article with numerous options, I have included two powerful ways to get you almost every detail possible related to disks.
Use the df command to check disk space
I know that I've already shown how you can use the df command to check the disk space but it can get you more than just listing drives.
By default, the df command will get your drives listed with all the options:
But what if you want to target the specific filesystem? It can easily be done by specifying the mounting port.
For example, if I want to know the disk usage of disks that are mounted at
boot partition, I would have to use the following command:
df -h /boot
The df command also allows you to customize the output field using the
Let's say I want only 4 columns indicating the source, used, available, and mounting points so I will be using the following command:
df -h --output=source,used,avail,target
Use the duf command to check disk space in Ubuntu
The duf utility is an enhanced version of the du and df utility combined together as it can be used to check both used and free space.
Unlike df, duf doesn't come preinstalled. First, let's install the duf utility in Ubuntu:
sudo apt install duf
Once done, all you need to do is simply type
And as you can see, even without additional options, it gets almost every crucial detail you wish to have.
But you may not want to list all the drives as it will clutter the entire window. And in that case, you can specify the drives.
For example, here, I used the duf to get details of the home directory and my external drive:
duf /home /media/sagar/HDD
Want to sort the output based on disk usage? duf will do.
To sort the output, you will need to use the
--sort option. And in my case, I want to sort the output based on disk usage so I will be using the following command:
duf --sort usage
To learn more about the duf command, I would highly recommend you the detailed guide on how to use the duf command in Linux.
I personally use the duf command as I find the output more meaningful than the plain df command.
But that's what I think and I would love to read your thoughts on what you'd prefer while dealing with various drives on a daily basis.
On a related topic, you might want to learn about ways to free up disk space on Ubuntu.
Also, if you have any queries or suggestions (tools that you use apart from these two), I would love to know them.