LinuxCommandLibrary

df

Show disk space usage

TLDR

Display all filesystems and their disk usage (using 512-byte units)

$ df
copy

Display the filesystem containing the specified file or directory
$ df [path/to/file_or_directory]
copy

Use [k]ibibyte (1024 byte) units when showing size figures
$ df -k
copy

Display information in a portable way
$ df -P
copy

SYNOPSIS

df [OPTION]... [FILE]...

PARAMETERS

-a, --all
    include pseudo, duplicate, inaccessible filesystems

-B, --block-size=SIZE
    use SIZE-byte blocks (e.g., 1K, 1M)

-h, --human-readable
    print sizes in powers of 1024 (1K, 1M, etc.)

-H, --si
    like -h, but use powers of 1000

-i, --inodes
    list inode usage instead of blocks

-k
    like --block-size=1K

-l, --local
    limit to local filesystems

--output[=FIELD_LIST]
    specify output fields (e.g., used,avail)

--sync
    invoke sync before reporting

--total
    elide small entries; produce grand total

-t, --type=TYPE
    limit to filesystems of type TYPE (e.g., ext4)

-T, --print-type
    print filesystem type

-x, --exclude-type=TYPE
    exclude filesystems of type TYPE

--help
    display help and exit

--version
    output version information and exit

DESCRIPTION

The df command displays disk space usage for mounted filesystems, showing total size, used space, available space, usage percentage, and mount points. It queries kernel statistics via system calls like statvfs(2), providing a quick overview of storage status.

Default output includes all filesystems:
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       50G  20G  28G  42% /

Essential for monitoring disk health, preventing outages from full drives. Options customize output: human-readable sizes (-h), inode counts (-i), or totals (--total). Specify files/directories to report their filesystems. Unlike du, it shows filesystem-level data, not subtree usage. Accurate for local mounts; remote filesystems (NFS) depend on connectivity. Run as root for all details; non-root skips some pseudo-filesystems.

CAVEATS

Reports filesystem totals, not directory subtrees (use du). Reserved blocks (e.g., 5% for root) reduce 'Avail'. Remote filesystems may lag or fail. Non-root users see limited pseudo-filesystems. Sizes may not sum exactly due to metadata.

TYPICAL OUTPUT COLUMNS

Filesystem (device), Size (total), Used, Avail (free), Use% (percentage), Mounted on (path)

EXAMPLES

df -h (human-readable all FS)
df -h /home (just /home FS)
df -i -t ext4 (inodes on ext4 FS)

HISTORY

Originated in Version 7 Unix (1979). GNU coreutils version since 1987, maintained by Free Software Foundation. Evolved with filesystem support (ext4, btrfs, NFS). Man page standardized in POSIX.1-2008.

SEE ALSO

du(1), mount(8), free(1), lsblk(8), statvfs(2)

Copied to clipboard