If you are managing a Linux server without a graphical user interface (GUI)—such as a headless Raspberry Pi or an AWS EC2 instance—you cannot simply open a file manager to see how much storage space you have remaining. If your server runs out of disk space, it will likely crash, corrupt databases, and refuse to boot.
To prevent this catastrophe, you must learn how to check free disk space in Linux. The most critical, foundational tool for this job is the df (Disk Free) command. It allows you to instantly view the total capacity, used space, and available space on every storage drive connected to your system.
What is the df Command?
The df command is a built-in core utility found in every modern Linux distribution, including Ubuntu, Debian, CentOS, and Fedora. While the du (Disk Usage) command is used to calculate the size of individual files and directories, df is designed to look at the entire file system as a whole.
If you open your terminal and simply type df, you will receive a massive wall of text detailing every single mount point on your machine. However, the output will be displayed in 1K blocks (kilobytes), which is incredibly difficult for a human to read at a glance.
Using the Human-Readable Flag (df -h)
To make the output useful, you must use the -h flag. This stands for “human-readable,” and it forces Linux to automatically convert those massive kilobyte numbers into familiar Megabytes (MB), Gigabytes (GB), and Terabytes (TB).
- Open your terminal application or connect to your server via SSH.
- Type the following command:
df -h - Press Enter.
You will now see a neatly formatted table. The most important column for a desktop or server user is usually the one mounted on /, which represents the “root” file system where your operating system and user data live. Look at the Avail (Available) and Use% columns to quickly determine if you are running out of storage.
Filtering the Output
Modern Linux distributions create dozens of virtual, temporary file systems (like tmpfs and snap) that run entirely in RAM. These virtual drives clutter the df output, making it harder to find your actual, physical hard drives.
Ignore Virtual File Systems (df -x)
If you are using Ubuntu, you likely have dozens of “snap” packages creating a mess in your terminal. You can use the -x flag (exclude) to tell the command to hide specific file system types.
To hide all snap loop devices and temporary memory file systems, run:
df -h -x squashfs -x tmpfs
Show Only Real Hard Drives (df -t)
Alternatively, if you only want to see your physical hard drives (which are typically formatted in `ext4`, `xfs`, or `btrfs`), you can use the -t flag (type) to exclusively show those drives.
To view only your main ext4 partitions, run:
df -h -t ext4
Checking a Specific Directory
If you have multiple hard drives mounted to your server (for example, a secondary drive specifically for backups), you can check the free space on that exact drive without printing the entire system table.
Simply append the file path to the end of your command:
df -h /mnt/backups
This will instantly display the capacity, usage, and available gigabytes exclusively for that specific storage location, allowing you to monitor your system health efficiently.