df - Linux
Overview
The df
command in Linux stands for “disk free” and is used to report the amount of disk space used and available on file systems. This command helps users manage disk space by providing summaries of available and used disk capacities. It’s particularly useful in server environments and when monitoring system health and capacity.
Syntax
df [OPTIONS]... [FILE]...
- [OPTIONS]: These are flags or arguments that modify the behavior of the command.
- [FILE]: Optionally specify one or more files or directories to report on their file systems.
Options/Flags
-a
,--all
: Include dummy file systems in the output.-h
,--human-readable
: Print sizes in a human-readable format (e.g., 1K, 234M, 2G).-H
: Similar to-h
, but uses powers of 1000 not 1024.-i
,--inodes
: List inode information instead of block usage.--total
: Produce a grand total.-k
: Display sizes in kilobytes (default).-l
,--local
: Limit the listing to local file systems.-T
,--print-type
: Show file system type.--sync
: Invoke sync before getting file system usage; ensures up-to-date information.-t
,--type=TYPE
: Limit listing to file systems of type TYPE.-x
,--exclude-type=TYPE
: Exclude file systems of type TYPE.--no-sync
: Do not invoke sync before getting file system usage (default behavior).
Examples
- Basic Usage: Show disk space usage of all mounted file systems:
df
- Human-Readable Format: Display the disk space in a more readable format:
df -h
- Specific File Systems: Show only the disk usage of type ‘ext4’:
df -t ext4
- Exclude File System Types: Avoid listing ‘tmpfs’ and ‘devtmpfs’ types in the output:
df -x tmpfs -x devtmpfs
- Display Inode Information: Report on inodes instead of block usage:
df -i
Common Issues
- Exceeding File System Inodes: Users might ignore the inode limits as
df
primarily focuses on block usage. To monitor inodes, usedf -i
. - Permission Denied: Running
df
may result in “Permission Denied” for certain directories. Running it withsudo
may be required. - Output Overwhelming: Particularly on systems with many mounts, the output might be excessive. Filtering with
-t
or-x
can make the output manageable.
Integration
Combine df
with other tools like grep
for more effective space management:
df -h | grep '/dev'
This command chain helps focus on specific devices. It can be used in scripts or cron jobs to monitor disk usage regularly.
Related Commands
du
– estimates file space usage.fdisk
– manipulates disk partition table.mount
– mounts file systems.
For further details on the usage and options, consult the man page (man df
) or the GNU Coreutils online documentation: GNU Coreutils – df.