The df
command in Unix-like operating systems is used to display information about disk space usage on filesystems. It stands for "disk free". Here’s an overview of df
and its common usage:
Purpose: df
is used to report the amount of disk space used and available on filesystems mounted in the system.
Availability: df
is a standard command-line utility available on Unix-like systems, including Linux distributions, macOS, and BSD variants.
-
Display Disk Space Usage for All Filesystems:
- To display information about all mounted filesystems:
By default,
df
df
displays information in 1 KB blocks.
- To display information about all mounted filesystems:
-
Display Disk Space Usage in Human-Readable Format:
- To display disk space usage in a more human-readable format (e.g., in kilobytes, megabytes, gigabytes):
The
df -h
-h
option (or--human-readable
) converts sizes into a human-readable format.
- To display disk space usage in a more human-readable format (e.g., in kilobytes, megabytes, gigabytes):
-
Display Disk Space Usage for Specific Filesystem:
- To display disk space usage for a specific filesystem (e.g.,
/dev/sda1
):Replacedf -h /dev/sda1
/dev/sda1
with the device or mount point you want to inspect.
- To display disk space usage for a specific filesystem (e.g.,
-
Display Filesystem Type:
- To display the type of filesystem along with disk space usage:
The
df -T
-T
option (or--print-type
) adds a column showing the filesystem type.
- To display the type of filesystem along with disk space usage:
-
Display Inode Usage:
- To display inode usage (number of used and available inodes) instead of disk space:
The
df -i
-i
option (or--inodes
) switchesdf
to report inode usage instead of disk space.
- To display inode usage (number of used and available inodes) instead of disk space:
-
Display Total Disk Space Usage:
- To display the total disk space usage across all filesystems:
The
df -h --total
--total
option provides a summary at the end of the output, showing the total used and available disk space.
- To display the total disk space usage across all filesystems:
-
Reserved Space: By default,
df
shows the amount of disk space available to ordinary users. Some filesystems reserve a percentage of disk space for root user (root-reserved
). This reserved space is not shown as available to normal users. -
Symbolic Links:
df
does not follow symbolic links. It reports on the filesystem that contains the symlink's target. -
Performance Impact: Running
df
on large filesystems or with the-i
option for inode information can be resource-intensive.
-
pydf: A Python-based tool that provides an enhanced and colorful output of disk usage, similar to
df
. -
Disk Usage Analyzers: Graphical tools like
Baobab
(for GNOME) andFilelight
(for KDE) offer visual representations of disk usage.
df
is a fundamental command-line tool for monitoring disk space usage on Unix-like systems, providing essential information about available storage and filesystem types. It’s useful for managing disk resources, identifying available space, and planning storage allocation.
df [options] [filesystems]
Display filesystem disk space usage.
Options:
-a, --all show all filesystems
-h, --human-readable print sizes in human-readable format
-k, --kilobytes use 1024-byte blocks
-m, --megabytes use 1048576-byte blocks
-t, --type=TYPE show only filesystems of the specified type
-T, --print-type print the filesystem type
-H, --si use powers of 1000 instead of 1024
-i, --inodes print inode usage
-x, --exclude=FSTYPE exclude filesystems of the specified type
-P, --portability print in a format compatible with other systems
-S, --sync force filesystems to be synced before displaying information
-v, --verbose print more information
-?, --help display this help message
Examples:
df
df -h
df -T
df -i
df -x ext4