Skip to content

df Command - Disk Space Analysis

Summary

The df command is a powerful tool used to report file system disk space usage. It displays information about the total space, used space, available space, and mount points of file systems. It is useful for monitoring disk usage and identifying potential space issues.

Introduction

The df command (short for "disk free") is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access. df is typically used to check remaining space on a disk partition. It is a fundamental command for system administrators and users alike to monitor and manage storage resources on a Linux system.

Use case and Examples

Basic Usage - Display disk space usage in human-readable format

df -h
This command displays disk space usage for all mounted file systems in a human-readable format (e.g., using units like K, M, G, T). This is generally the most convenient way to use df.

Display disk space usage for a specific file system

df /home
This command shows disk space usage specifically for the file system mounted at /home.

Display inode information instead of block usage

df -i
This command displays the number of used and free inodes on the file system, rather than disk space. Inodes are data structures used to represent file system objects.

Display disk space usage in KB

df -k
This command displays disk space usage in kilobytes.

Exclude a specific filesystem type

df -x tmpfs
This command shows disk space usage, excluding the tmpfs filesystem type, which is often used for temporary filesystems in memory.

Commonly used flags

Flag Description Example
-h or --human-readable Display sizes in human readable format (e.g., 1K 234M 2G). df -h
-i or --inodes List inode information instead of block usage. df -i
-k Display sizes in kilobytes. df -k
-m Display sizes in megabytes. df -m
-T or --print-type Print the filesystem type. df -T
-x <type> or --exclude-type=<type> Exclude filesystems of type <type>. df -x tmpfs
-a or --all Include pseudo, duplicate, and inaccessible file systems in the listing. df -a
--total Produce a grand total. df --total


Share on Share on

Comments