Hello, friends. Many times we have to ask ourselves how much disk space is left. Well, although a silly question, we can answer it using the terminal, so it becomes essential for many sysadmins.
Many times we store so much information on our hard disk that we forget how much space is left and if we use a server, then maybe even less clue. For a new Linux user this may be a problem to know, but for an experienced user perhaps not so much.
Find out how much disk space is left
To do this post, we have several tools that you can use. Each of them is different but serves the purpose.
Method 1: df command
The df command is a tool that allows us to know the space usage of each disk drive.
Therefore, we will be able to use it to know the remaining space on our hard disk, broken down and in a format quite readable for all of us.
One of the advantages of using this command is that it is installed by default in almost all current Linux distributions. So, you don’t need to install anything.
So, to use it, open a terminal, and you can invoke the command like this
df
Sample output
Filesystem 1K-blocks Used Available Use% Mounted on
udev 969944 0 969944 0% /dev
tmpfs 198156 512 197644 1% /run
/dev/sda1 19484408 1416744 17225104 8% /run
tmpfs 990768 0 990768 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
/dev/sda15 122961 142 122820 1% /boot/efi
tmpfs 198152 0 198152 0% /run/user/0
The issue is that this screen output shows the data in not very understandable values. However, if you add the -h
option, you will have a more user-friendly output.
df -h
Now, as you can see, things change.
![Find out how much disk space is remaining with du command](https://unixcop.com/wp-content/uploads/2023/04/du-command.png)
The screen output is simple. From there you can see the file systems and therefore the drives of the system. You will be able to see the size of them as well as the used and available.
It is perhaps the best way to get the desired answer.
Method 2: The pydf command displays a colored screen output
The pydf command will also display an output screen with the system’s disk usage. The difference is that it displays it in a colorful and quite friendly way, but it is not installed by default.
In the chaos of Debian and its derivatives, it will suffice to run
sudo apt install pydf
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
pydf
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 12.8 kB of files.
After this operation, 46.1 kB of additional disk space will be used.
Now you can use it as follows:
pydf -h
Sample output:
![Using the pydf command to show the disk](https://unixcop.com/wp-content/uploads/2023/04/pydf.png)
Even more than df, the screen output is more explicit and more readable for us. This utility is quite usable in scripts or configurations.
Conclusion
This post, oriented to all users in general, has been of great help to know the remaining disk space using the terminal, so you can use it in many circumstances.