Introduction to df command
The df command (short disk free) is a key tool in any Linux distribution that allows you to obtain quick information about the use of space in mounted file systems. Its output shows, for each assembly point, the total size, the space used, the free space and the percentage of use. This information is essential for system administrators, developers and any user who needs to monitor storage capacity and avoid surprises such as a full disk that can interrupt services or cause file writing failures.
Basic syntax
The simplest way to run df is simply to write df in the terminal. Without options, the command shows the information in 1 kilobyte blocks, which may be unreadable on high-capacity disks. To make the output more friendly you usually add the -h (human-readable) option, which converts the numbers to units like K, M, G as needed. One or more file systems or assembly points can also be specified as arguments to limit consultation to specific devices.
Most commonly used options
-h: shows the sizes in readable format (KB, MB, GB).-T: includes the type of file system (ext4, xfs, btrfs, etc.) in an additional column.-a: displays all file systems, including those that are zero-sized or pseudo-systems such as proc, sysfs and tmpfs.-i: instead of disk space, it shows the use of inodes, useful to detect file structures exhaustion.-t: Filters output to include only file systems of the specified type.-x: excludes file systems of the type indicated.
Practical examples
-
See the use of all disks in readable format:
df -h -
Include file system type:
df -hT -
Show only the ext4 file systems:
df -h -t ext4 -
Exclude tmpfs file systems (useful to ignore virtual memory):
df -h -x tmpfs -
Consult the use of noodles in the root partition:
df -i / -
Get information from a specific assembly point, for example / home:
df -h /home
Interpretation of the exit
Each column of df output has a concrete meaning. The first column indicates the name of the device or file system (as / dev / sda1). The second shows the total size of the file system. The third indicates the space already used. The fourth shows the space available for writing. The fifth percentage column represents the proportion of the space used over the total. When using the -T option, an additional column with the file system type appears, which helps quickly identify if you are working with ext4, xfs, btrfs, nfs, etc. If used -i, the size columns are replaced by the total number of inodes, used inodes and free inodes, together with their percentage of use.
Tips and tricks
- Combine df with other commands using pipes to filter results, for example
df -h | grep '/dev/sd'to show only physical records. - Use command
watch df -hto observe in real time how the use of the disk varies while running an intensive task in I / O. - In administration scripts, check the percentage of use and activate alerts when you exceed a threshold (e.g. 90%) using constructions such as
df -h / | awk 'NR==2 {print $5}'and comparing the numerical value. - Remember that the file systems mounted in read-only mode will show the space used but will not allow to write; df will continue to report the free space according to total capacity.
- In containers or virtualization environments, df can display host file system information; to see the container's internal space use specific tools such as
docker system df.
Conclusion
The df command is one of those simple but powerful utilities that are a day-to-day part of any Linux user. Knowing your syntax, your most common options and how to interpret your output allows you to efficiently manage disk space, prevent capacity problems and make informed decisions about cleaning, expansion or reconfiguration of storage systems. Practice with the examples presented and explore the help pages (man df) will consolidate the domain of this essential tool.


