The df (Disk Filesystem) Command
Overview
The df (disk filesystem) command reports how much disk space is used and available on mounted filesystems. While du shows the size of specific directories, df gives you the big picture of your entire disk or partition.
Basic Syntax
df [options] [filesystem]
Running df without arguments shows all mounted filesystems.
Common Usage Examples
Human-Readable Disk Space Overview
df -h
Sample output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 32G 16G 67% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sda2 200G 145G 45G 77% /home
Understanding the Output Columns
| Column | Description |
|---|---|
| Filesystem | The name of the storage device or partition |
| Size | Total capacity of the filesystem |
| Used | Amount of space currently in use |
| Avail | Free space remaining |
| Use% | Percentage of the filesystem that is used |
| Mounted on | The directory where the filesystem is accessible |
Check a Specific Filesystem or Path
df -h /home
This shows only the filesystem that contains /home, which is helpful when you want to check a specific partition.
Display Filesystem Type
df -hT
The -T flag adds a Type column showing the filesystem type (ext4, xfs, tmpfs, etc.):
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 50G 32G 16G 67% /
/dev/sda2 xfs 200G 145G 45G 77% /home
Useful Flags Reference
| Flag | Description |
|---|---|
-h | Human-readable sizes (KB, MB, GB) |
-H | Human-readable using powers of 1000 instead of 1024 |
-T | Show filesystem type |
-i | Show inode usage instead of block usage |
-a | Include pseudo, duplicate, and inaccessible filesystems |
-t TYPE | Show only filesystems of a specific type |
-x TYPE | Exclude filesystems of a specific type |
--total | Append a grand total row |
Practical Use Cases
Monitor overall server disk usage
df -h --total
This appends a total row summarizing all filesystems.
Check inode usage
Sometimes you run out of inodes (file entries) before running out of space. This is common when a directory contains millions of small files (e.g., mail or cache directories):
df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 3.2M 420K 2.8M 13% /
/dev/sda2 13M 1.1M 12M 9% /home
Filter output to real (non-tmpfs) filesystems
df -h -x tmpfs -x devtmpfs
df vs. du
| Tool | Purpose |
|---|---|
df | Shows total, used, and free space for entire filesystems/partitions |
du | Shows how much space specific directories or files consume |
Use df -h first to see if a partition is running low, then use du to investigate which directories are the largest consumers.
Tips
- On shared hosting,
dfoutput may be limited or show the entire server’s disk — your hosting provider may offer a disk usage widget in cPanel for account-level details. - If
Use%is above 90%, take action immediately by cleaning up old backups, logs, or temporary files. - If inode usage (
df -i) is high, look for directories with excessive small files such as cache or session directories.