Linux df Command: Check Filesystem Free Space

df shows the total size, usage, and available space for each mounted file system. It is used to check if the disk is full, and its scope is different from du, which calculates capacity per directory.

What is the df command?

df reads the space statistics of the file system instead of summing up individual files. Avail indicates the space available to the general user, and if there are reserved blocks, it may not exactly match the value of total size minus used space. Even if there is block space remaining, if inodes run out, new files cannot be created.

Basic syntax

df [options] [file or mount point]

The installed implementation and options may vary depending on the distribution. Check the description for the current system with man df.

Examples

Total file system capacity

Check the mounted file systems in human-readable units.

df -h

File system of a specific path

Check the available space of the file system to which the specified path belongs.

df -h /var

inode usage

If there is space left but file creation fails, check for inode exhaustion.

df -i /var

Reading File System Usage

df shows the space of the file system that the path belongs to, not the size of a single file. If you specify only the root path, you can narrow the scope to the related mount entries.

df -h /

Example output (capacity and device names vary by environment):

Filesystem  Size  Used Avail Use% Mounted on
/dev/sda2    40G   18G   20G  48% /

Avail is the space available to regular users and may not equal Size - Used due to reserved blocks on the file system. If df shows full but the total file size seems small, check for files that have been deleted but are still open by processes, or other mounted or reserved areas. Disk usage by directory is handled by du.

Main Options and Format

Options/Format Description
-h Display sizes in human-readable units.
-T Display the filesystem type as well.
-i Display inode usage instead of blocks.
-t format Only display the specified filesystem type.
--output=fields Select the required output columns.

Precautions when using

On network, container, and overlay file systems, the same storage space may appear in multiple rows. If the df and du results differ, check for deleted files that processes still have open, reserved blocks, snapshots, etc. Do not assume fixed column positions in automation for default output.

Frequently Asked Questions

Why do df and du show different values?

df reports overall file system space statistics, while du sums up the usage of accessible files and directories. Open deleted files, etc., can cause differences between the two results.

Official Documentation

For the exact behavior of options and implementation-specific differences, see the official df documentation.

More in This Category
Linux umount Command: Unmount a Filesystem Safely

Linux umount Command: Unmount a Filesystem Safely

Learn how to unmount a Filesystem Safely with the Linux umount command, including practical examples, key options, and important precautions.

Linux lscpu Command: Inspect CPU Architecture and Cores

Linux lscpu Command: Inspect CPU Architecture and Cores

Learn how to inspect CPU Architecture and Cores with the Linux lscpu command, including practical examples, key options, and important precautions.

Linux dnf Command: Manage RPM Distribution Packages

Linux dnf Command: Manage RPM Distribution Packages

Learn how to manage RPM Distribution Packages with the Linux dnf command, including practical examples, key options, and important precautions.

Linux last Command: Review Login and Reboot History

Linux last Command: Review Login and Reboot History

Learn how to use the Linux last command to review user login sessions, system reboots, and shutdown history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux apt-get Command: Run APT Package Operations in Scripts

Linux apt-get Command: Run APT Package Operations in Scripts

Learn how to run APT Package Operations in Scripts with the Linux apt-get command, including practical examples, key options, and important precautions.

Linux uniq Command: Remove or Count Adjacent Duplicate Lines

Linux uniq Command: Remove or Count Adjacent Duplicate Lines

Learn how to remove or count adjacent duplicate lines with the Linux uniq command, including practical examples, key options, and important precautions.

Linux systemctl Command: Manage systemd Services

Linux systemctl Command: Manage systemd Services

Learn how to manage systemd Services with the Linux systemctl command, including practical examples, key options, and important precautions.

Linux rm Command: Remove Files and Directories Safely

Linux rm Command: Remove Files and Directories Safely

Learn how to remove files and directory trees with Linux rm, use interactive safeguards, limit recursive deletion, and avoid destructive path mistakes.

Linux csplit Command: Split Files at Lines or Patterns

Linux csplit Command: Split Files at Lines or Patterns

Learn how to split Files at Lines or Patterns with the Linux csplit command, including practical examples, key options, and important precautions.

Linux dig Command: Query DNS Records in Detail

Linux dig Command: Query DNS Records in Detail

Learn how to query DNS Records in Detail with the Linux dig command, including practical examples, key options, and important precautions.