Share your love
How To Display Disk Space on Ubuntu 22.04
In this tutorial, we want to teach you to Display or Check Disk Space on Ubuntu 22.04.
Disk Space is defined as a utility that helps the user with the space left in the system’s disk. Within this utility itself, numerous sub-utilities allow the user to perform specific tasks. A few examples of such tasks are managing the disk space, checking the disk space, freeing up the disk space, etc.
Steps To Display Disk Space on Ubuntu 22.04
To complete this guide, you must log in to your server as a root or non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Ubuntu 22.04.
Check Disk Space with df Command
The df command displays the amount of disk space available on the filesystem with each file name’s argument.
You can simply use the command below:
df
You will get something similar to this:
Output
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 288237920 35699668 237873500 14% /
none 4 0 4 0% /sys/fs/cgroup
udev 1950372 4 1950368 1% /dev
tmpfs 392664 4548 388116 2% /run
none 5120 0 5120 0% /run/lock
...
If you want to check disk space usage in human-readable format, use the -h option:
df -h
Output
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 275G 35G 227G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 1.9G 4.0K 1.9G 1% /dev
tmpfs 384M 4.7M 379M 2% /run
none 5.0M 0 5.0M 0% /run/lock
...
Check File System Type on Ubuntu 22.04
At this point, you can easily use the df command with the -T option to display the file system type:
df -T
Output
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 288237920 35700492 237872676 14% /
none tmpfs 4 0 4 0% /sys/fs/cgroup
udev devtmpfs 1950372 4 1950368 1% /dev
tmpfs tmpfs 392664 4976 387688 2% /run
none tmpfs 5120 0 5120 0% /run/lock
...
To display the information about the ext4 partition, run the following command:
df -t ext4
Output
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 288237920 35700936 237872232 14% /
/dev/sda5 187308940 37156240 140614908 21% /Data
ext4 is the default file system for many Linux distributions including Debian and Ubuntu.
Check Disk Space with du command on Ubuntu 22.04
The du (disk usage) command measures the disk space occupied by files or directories.
To display the disk space usage of your current directory, you can use the command below:
du
Output
4 ./.cache
4 ./opennms/overlay
12 ./opennms
32 .
And, to display the information in human-readable format, run the following command:
du -h
Output
4.0K ./.cache
4.0K ./opennms/overlay
12K ./opennms
32K .
To display the total disk space usage of the specified directory, you can use the -hs option:
du -hs /var/log
Output
848K /var/log
Also, you can use the du command with the sort parameter to sort the files and directories by size:
du -h | sort -rn
Output
32K .
12K ./opennms
4.0K ./opennms/overlay
4.0K ./.cache
Conclusion
At this point, you have learned to Display or Check Disk Space on Ubuntu 22.04.
Hope you enjoy it. You may be like these articles: