Check free disk space on Linux in seconds with built-in commands. Open a terminal and run `df -h` to see usage across all partitions, formatted clearly with human-readable sizes. This is the most common and reliable way—no extra software needed.
What You'll Need
- A Linux system (Ubuntu, Fedora, Arch, Debian, or any Linux distro) with a terminal open.
- No special permissions—most commands work as the current user.
- Basic familiarity with Linux commands (like `ls`, `cd`) helps but isn’t required.
Step-by-Step
- Open a terminal:
- Press
Ctrl + Alt + T(most desktop environments) or search for "Terminal" in your apps menu. - On some minimal setups, pressCtrl + Shift + Tif no shortcut works. - Run the `df` command to display disk usage for all mounted filesystems:
sudo df -h(Usesudoonly if you need root access for specific filesystems, like the root partition.) - The output will show columns like/dev/sda1(device),50G(size),48G(used),2G(available), and99%(percentage used). - The-hflag formats sizes in human-readable units (GB, MB, etc.). - Filter for a specific partition if you need details on one drive, such as `/home` or `/var`:
df -h /path/to/directoryFor example:df -h /hometo check the/homepartition’s free space. - Check only free space (less common but useful for optimization):
df -h --output=source,availThis narrows results to the device name and free space, useful for scripts or filtering.
Common Mistakes
- Forgetting `-h`: Without it, sizes appear in bytes (e.g., 4294967296B). Use -h to see GB/MB.
- Running `df` without `sudo` on root-mounted filesystems: This may show incorrect or incomplete data for critical partitions like
/or/boot. Only skip sudo if you’re sure you’re checking user-owned partitions. - Misinterpreting output: The
availcolumn shows *suggested* free space, not always usable (e.g., swap space may not be usable).
Tips
- Compare with filesystem types: Some filesystems (e.g., ext4, XFS) report available space differently. Use `df -x type` to exclude a filesystem (e.g.,
df -x tmpfsto ignore RAM cache). - Add human-readable units: Chain commands like
df -h | awk '$NF < 10 {print $6, $1}'to flag partitions below 10% used. - Use `du` for directory-level space: For checking space in specific folders (not filesystems), run
du -sh /path/to/folder. - Monitor changes: For tracking free space over time, log results to a file:
df -h > disk_usage.logThen review logs withtail -f disk_usage.log.
Troubleshooting
- Command not found: Ensure your system has `df` installed. Most Linux distros include it by default. If missing, install it with:
sudo apt install coreutils(Debian/Ubuntu)sudo pacman -S coreutils(Arch) or your package manager. - Output shows 0B for available space:
- The partition may be full or corrupted. Check with:
sudo fsck /dev/sdX(replacesdXwith your device, e.g.,sda1). - If fsck fails, recover data from backups immediately. - No output at all:
- Verify you’re on a valid filesystem by checking mounted devices:
mountorlsblk. - If no filesystems appear, your system may be unbootable (check BIOS/UEFI settings). - Permission denied: - The target filesystem is protected (e.g., `/boot` or `/`). Use `sudo` or check if the partition is mounted read-only.
Frequently Asked Questions
1. How do I check free space for a specific filesystem (e.g., NTFS from a Windows share)?
Use df -h /mnt/share_name to check the mounted filesystem (replace share_name with the mount point). If NTFS, ensure the kernel supports it (most modern Linux kernels do).
2. What does the "use%" column mean in `df`?
This shows the percentage of the filesystem’s capacity used. A 95% value means only 5% is free. This includes free space available to the filesystem, not necessarily usable for all applications.
3. Can I check free space for a swap partition?
Swap partitions report free space differently than data partitions. Use df -h /dev/sdX to see swap’s free space. Note: Swap is not a storage device—it’s memory backupspace. Always prioritize free data space over swap.
4. How do I ensure I’m checking the right filesystem?
Run lsblk to list all block devices and their labels. Match the device name (e.g., /dev/sda1) with the partition you want to check.
5. Why does `df` show "no space left on device" when I have disk space?
This can happen if:
- The filesystem is corrupted (run
sudo fsck), - Files are locked by another process (check with
lsof | grep /full/path), or - A metadata error exists (try
sudo e2fsck -f /dev/sdXfor ext2/ext3/ext4).
Check for these issues before assuming the disk is full.
6. How can I check free space for a mounted network drive (NFS/CIFS)?
Mount the drive first (e.g., via sudo mount -t cifs //server/share /mnt/share). Then run df -h /mnt/share. Network shares may have different reporting than local drives.