Disk Free (df) Command - View Disk Space Usage | Online Free DevTools by Hexmos

View disk space usage with the df command. Learn how to display free disk space in human-readable format, by file system type, and inode usage.

Disk Free (df) Command

The df command (short for "disk free") is a standard Unix and Linux command-line utility that reports file system disk space usage. It displays the amount of disk space used and available on file systems. Understanding disk usage is crucial for system administration, performance monitoring, and preventing storage-related issues.

View Disk Space Usage

The primary function of the df command is to show how much space is used and available on your mounted file systems. This helps in identifying which partitions or drives are running low on space.

Human-Readable Disk Space

To make the output easier to read, you can use the -h option. This displays sizes in powers of 1024 (e.g., KB, MB, GB).

# df -h
# Report file system disk space usage in a human-readable format.
df -h

Filter by File System Type

You can filter the output to show only specific file system types using the -t option, or exclude certain types with the -x option.

# Free disk space for [t]ype EXT2 file systems.
df -t ext2

# Free disk space for filesystems, e[x]cluding EXT2.
df -x ext2

Check Inode Usage

Besides block usage, it's also important to monitor inode usage. Inodes are data structures that store information about files and directories. Running out of inodes can prevent new files from being created, even if there's free disk space. Use the -i option to view inode usage.

# Show [i]node usage.
df -i

Display Specific File System Information

To get information about a particular file system or mount point, specify the path.

# Show information about a distinct filesystem path.
df [PATH]

Show All File Systems

The -a option displays all file systems, including pseudo, duplicate, and inaccessible ones, providing a comprehensive view.

# List [a]ll filesystems, + unreadable, duplicates, pseudo, and inaccessible.
df -a

Grand Total Disk Usage

To get a summary of the total disk usage across all mounted file systems, use the --total option.

# Fetch a grand total of disk usage.
df --total

External Resources: