LinuxCommandLibrary

df

Show disk space usage

TLDR

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

$ df
copy

Display the filesystem and its disk usage containing the given file or directory
$ df [path/to/file_or_directory]
copy

Use 1024-byte units when writing space figures
$ df -k
copy

Display information in a portable way
$ df -P
copy

SYNOPSIS

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

PARAMETERS

-a, --all
    Include pseudo, duplicate, inaccessible file systems.

-B, --block-size=SIZE
    Scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below.

-h, --human-readable
    Print sizes in human readable format (e.g., 1K 234M 2G).

-H, --si
    Likewise, but use powers of 1000 not 1024.

-i, --inodes
    List inode information instead of block usage.

-k
    Like --block-size=1K.

-l, --local
    Limit listing to local file systems.

-P, --portability
    Use POSIX output format.

-t, --type=TYPE
    Limit listing to file systems of type TYPE.

-T, --print-type
    Print file system type.

-x, --exclude-type=TYPE
    Limit listing to file systems not of type TYPE.

--sync
    Invoke sync before getting usage info.

--total
    Produce a grand total.

-v
    Ignored.

DESCRIPTION

The df command in Linux is used to display the amount of disk space available on file systems. It provides a snapshot of how much space is being used and how much is free on each mounted filesystem. This is essential for system administrators and users to monitor storage capacity and avoid running out of disk space.
The output typically includes information such as the filesystem name, total space, used space, available space, capacity percentage, and mount point. Options allow filtering by filesystem type, displaying in human-readable format (e.g., kilobytes, megabytes, gigabytes), and showing inode information. Understanding df output enables efficient disk management and helps prevent performance issues caused by full filesystems.

CAVEATS

The reported free space can sometimes be misleading due to reserved blocks for the root user or system processes. The results can also vary slightly depending on the underlying filesystem implementation. Pseudo filesystems will return 0 for total and used space.

SIZE FORMAT

SIZE may be (or may be an integer optionally followed by) one of following: KB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.
The command is only used for displaying file system usages so other commands like "fdisk" which are needed to create new partitions are not related.

HISTORY

The df command has been a part of Unix systems since the early days, providing a fundamental tool for disk space management. Its basic functionality has remained consistent, while improvements have been added over time, such as human-readable output and better support for different filesystem types. The core functionality allows system admins to identify drives that are running low on disk space.

SEE ALSO

du(1), mount(8)

Copied to clipboard