How much disk space have I utilized?
The simplest way to find the free disk space on Linux is to use df command. The df command stands for disk-free and quite obviously, it shows you the free and available disk space on Linux systems.
-h option, it shows the disk space in human-readable format (MB and GB).
Here’s the output of the df command for my Dell XPS system that has only Linux installed with encrypted disk:
If the above output is confusing for you, don’t worry. I’ll explain a few things about checking available disk space on Linux. I’ll also show the GUI method for desktop Linux users.
Overall, I’ll mention three methods:
With the information you gather, you can go about making some free space on Ubuntu.
Method 1: Checking free disk space in Linux with df command (and understanding its output)
When you use the df command to check disk space, it will show a bunch of ‘file systems’ with their size, used space and free space. Your actual disks should normally be listed as one of the following:
This is not a hard and fast rule but it gives you an indication to easily recognize the actual disk from the crowd.
Your Linux system might have several partitions on your disk for boot, EFI, root, swap, home etc. In such cases, these partitions are reflected with a number at the end of the ‘disk name’, like /dev/sda1, /dev/nvme0n1p2 etc.
You could identify which partition is used for what purpose from its mount point. Root is mounted on /, EFI in /boot/EFI etc.
In my case, I have used 41% of the 232 GB of disk space under root. If you have 2-3 big partitions (like root, home etc), you’ll have to make a calculation here.
- tmpfs: The tmpfs (temporary filesystem) used for keeping files in virtual memory. You can ignore this virtual filesystem comfortably.
- udev: The udev filesystem is used for storing information related to devices (like USB, network card, CD ROM etc) plugged to your system. You may ignore it as well.
- /dev/loop: These are loop devices. You’ll see plenty of them while checking disk space in Ubuntu because of snap applications. Loops are virtual devices that allow normal files to be accessed as block devices. With the loop devices, snap applications are sandboxed in their own virtual disk. Since they are under root, you don’t need to count their used disk space separately.
And, if you want to view the disk usage with more details like filesystem type and blocks, you can use the command:
Missing disk space? Check if you have mounted all disks and partitions
Keep in mind that the df command only shows disk space for mounted filesystems. If you are using more than one Linux distribution (or operating systems) on the same disk or you have multiple disks on your system, you need to mount them first in order to see the free space available on those partitions and disks.
For example, my Intel NUC has two SSDs and 4 or 5 Linux distributions installed on them. It shows additional disks only when I mount them explicitly.
You can use the lsblk command to see all the disks and partitions on your system.
Once you have the disk partition name, you can mount it in this fashion:
sudo mount /dev/sdb2 /mnt
I hope this gives you a pretty good idea about checking hard drive space on Linux. Let’s see how to do it graphically.
Method 2: Using du, ls, and Other Commands
While df command is quite popular and should be enough for the use case, there are other alternatives that you can try including:
- du -h → Shows disk usage in human-readable format for all directories and subdirectories.
- du -a →Shows disk usage for all files.
- du -s Provides the total disk space used by a particular file or directory.
- ls -al →Lists the entire contents, along with their size, of a particular directory.
- stat <file/directory> →Displays the size and other stats of a file/directory or a file system.
- fdisk -l →Shows disk size along with disk partitioning information (may require sudo privileges).
- dust → An interesting alternative to the du command written in Rust, available for Arch Linux in the repositories. For other Linux distros, you can refer to its GitHub releases section.
Method 3: Check free disk usage graphically
Checking free disk space graphically is much easier in Ubuntu with the Disk Usage Analyzer tool.
You’ll see all the actual disks and partitions here. You may have to mount some partitions by clicking on them. It displays the disk usage for all the mounted partitions.
Checking free disk space with GNOME Disks utility
Otherwise, the GNOME Disks utility is also a pretty handy tool.
Start the tool and select the disk. Select a partition to see the free disk space. If a partition is not mounted, mount it first by clicking the ‘play’ icon.
I think all major desktop environments have some sort of graphical tool to check the disk usage on Linux. You can search for it in the menu of your desktop Linux system.
Of course, there can be more ways and tools to check disk space. I showed you the most common command line and GUI methods for this purpose.
I also explained a few things that might trouble you in understanding disk usage. I hope you like it.
Running out of disk space? How about cleaning it up and get it back?
Please let me know in the comment section if you have questions or suggestions.