Monitoring disk space is a critical task for any Linux administrator. If a server’s primary partition reaches 100% capacity, system services can crash, databases can corrupt, and the machine may become entirely unresponsive.
Unlike Windows, which uses a graphical interface to display a single “C: Drive” capacity bar, Ubuntu utilises the terminal to display detailed information about every mounted file system, partition, and external drive. The quickest and most reliable way to check your available storage is by using the df command.
Using the ‘df’ Command
The df (Disk Free) command reports the amount of available and used disk space on all mounted file systems. While it provides excellent detail, running the command by itself outputs the sizes in raw 1K blocks, which are incredibly difficult for humans to read.
To make the output understandable, you should always use the -h (human-readable) flag.
- Open your terminal application (or connect via SSH).
- Type the following command and press Enter:
df -h
Understanding the Output
The terminal will return a table with several columns. Here is how to interpret the data:
- Filesystem: The name of the partition or virtual file system (e.g.,
/dev/sda1is usually your primary physical hard drive). - Size: The total capacity of that specific partition (e.g., 100G for 100 Gigabytes).
- Used: The amount of space currently occupied by files.
- Avail: The exact amount of free space remaining.
- Use%: The percentage of the partition that is currently full. (Keep a close eye on this number; anything above 90% requires immediate attention.)
- Mounted on: The directory where the file system is attached. The root directory is represented by a single forward slash (
/). This is your primary operating system partition.
Checking a Specific Directory
If you only care about the disk space of a specific physical drive or a particular mount point, you can append the path to the command.
For example, to check the available space specifically on the root partition, type:
df -h /
This filters the output, removing all the virtual snap loops and temporary file systems, displaying only the exact partition you requested.
Alternative: Using ‘lsblk’ for Disk Structure
While df -h shows available space on mounted file systems, it will not show you unmounted hard drives (e.g., a newly installed secondary SSD that hasn’t been formatted yet).
If you need to see the physical layout of all connected drives and their total capacities regardless of their mount status, use the lsblk (List Block Devices) command:
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT
This will display a clean tree structure of all physical drives (like sda or nvme0n1), their partitions, their total sizes, and where they are currently mounted.