Linux df
Command
In the realm of Linux and Unix-like operating systems, efficient disk space
management is a crucial aspect of system administration. The df
command is a powerful tool that provides essential insights into disk space
usage, allowing users and administrators to monitor storage availability,
identify space-hogging directories, and plan for storage upgrades. In this
blog
post, we will explore the df
command in depth, covering its
syntax,
options, and various practical applications.
Basic Syntax
The basic syntax of the df
command is simple:
bashdf options filesystem
options
: Additional flags that modify the behavior of thedf
command.filesystem
: The name of the filesystem to display information for. If omitted, it displays information for all mounted filesystems.
Displaying Disk Space Usage
To display disk space usage for all mounted filesystems, you can use the
df
command without any options.
bashdf
This will display information about each mounted filesystem, including the device, total space, used space, available space, percentage of usage, and the mount point.
Human-Readable Output
The -h
or --human-readable
option makes the output
more
human-readable by displaying sizes in a human-readable format (e.g., KB, MB,
GB).
bashdf -h
Displaying Filesystem Type
The -T
or --print-type
option displays the
filesystem
type for each filesystem.
bashdf -T
Excluding Specific Filesystems
The --exclude-type
option allows you to exclude specific
filesystem
types from the output.
bashdf --exclude-type=tmpfs
This will exclude tmpfs
filesystems from the output.
Practical Applications
-
Viewing Disk Space Usage:
bashdf
-
Displaying Human-Readable Output:
bashdf -h
-
Excluding Specific Filesystem Types:
bashdf --exclude-type=tmpfs
Advanced Usage
Displaying Inodes
The -i
or --inodes
option displays inode
information
for each filesystem, including the total inodes and used inodes.
bashdf -i
Displaying a Specific Filesystem
To display information for a specific filesystem, specify its name as an argument.
bashdf /dev/sda1
Monitoring Disk Space
You can use the watch
command to continuously monitor disk space
usage at a regular interval.
bashwatch -n 10 df -h
This will display disk space usage every 10 seconds.