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 chown Command: Change File Owner and Group

Linux chown Command: Change File Owner and Group

Learn how to change File Owner and Group with the Linux chown command, including practical examples, key options, and important precautions.

Linux getent Command: Query Users, Groups, and Other NSS Databases

Linux getent Command: Query Users, Groups, and Other NSS Databases

Learn how to query Users, Groups, and Other NSS Databases with the Linux getent command, including practical examples, key options, and important precautions.

Linux stat Command: Display Detailed File Metadata

Linux stat Command: Display Detailed File Metadata

Learn how to use the Linux stat command to inspect file size, permissions, ownership, timestamps, inode, and filesystem metadata, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux ln Command: Create Hard Links and Symbolic Links

Linux ln Command: Create Hard Links and Symbolic Links

Learn how to create hard links and symbolic links with Linux ln, choose relative or absolute targets, replace links safely, and inspect link behavior.

Linux ping Command: Test Host Reachability and Round-Trip Time

Linux ping Command: Test Host Reachability and Round-Trip Time

Learn how to test Host Reachability and Round-Trip Time with the Linux ping command, including practical examples, key options, and important precautions.

Linux head Command: Display the Beginning of a File

Linux head Command: Display the Beginning of a File

Learn how Linux head prints the first lines or bytes of files and pipelines, labels multiple inputs, excludes a trailing portion, and handles multibyte data.

Linux umask Command: Control Default File Permissions

Linux umask Command: Control Default File Permissions

Learn how to control Default File Permissions with the Linux umask command, including practical examples, key options, and important precautions.

Linux tar Command: Create and Extract Archives

Linux tar Command: Create and Extract Archives

Learn how to create and Extract Archives with the Linux tar command, including practical examples, key options, and important precautions.

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Use pwd, ls, cd, and tree to find your current location, inspect directories, navigate paths, and check where each command takes you.

Linux grep Command: Search Text and Filter Command Output

Linux grep Command: Search Text and Filter Command Output

Learn how to use the Linux grep command to search files for text or regular expressions and filter command output, with essential options, practical examples, output interpretation, and common troubleshooting tips.