This article is a follow-up to our previous post on +100 Linux Commands Frequently Used by Sysadmins. Each week, we’ll explore some of the most useful Linux commands for sysadmins and power users.

The df command is essential for monitoring disk space. It shows how much space is available on a particular file system and provides an overview of all mounted file systems.

What is the df Command?

The df (disk free) command is used on Linux and other Unix-like systems to display:

  • The amount of free disk space on your system.
  • Which filesystems are currently mounted.

By default, df displays disk usage for all mounted filesystems. If you provide a file or directory as an argument, it shows information only for the filesystem containing that file.

Understanding df Output

When you run df, you’ll see several columns:

ColumnDescription
FilesystemThe name of the disk partition or device.
SizeTotal size of the filesystem.
UsedSpace already used by files.
AvailableFree space left for new files.
Use%Percentage of the filesystem currently in use.
Mounted onDirectory where the filesystem is mounted.

For example, running:

df

might output:

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1       488281250 12345678 475935572  3% /
tmpfs            16384000       0  16384000  0% /dev/shm

Common df Options and Examples

1. Human-Readable Disk Usage

df -h
  • Shows sizes in KB, MB, or GB, making it easier to read.
READ 👉  How to Open or View a File in Linux Terminal (Beginner Guide)

2. Check Disk Usage for a Specific File or Directory

df /path/to/directory_or_file
  • Displays the filesystem containing that path.

3. Display Free Inodes

df -i
  • Shows the number of free inodes, which is useful for checking if you can create more files.

4. Exclude Specific Filesystem Types

df -x tmpfs
  • Excludes temporary filesystems (like tmpfs) from the output.

Quick Tips

  • Use df -hT to see both filesystem type and human-readable sizes.
  • Combine df with grep to filter for a specific mount point, e.g.:
df -h | grep '/home'
  • Keep an eye on Use% to avoid running out of disk space.

Conclusion

The df command is a lightweight yet powerful tool to monitor disk space on Linux and Unix-like systems. Whether you’re checking the free space on a single directory or getting a complete overview of all mounted filesystems, df is an essential command for sysadmins and power users alike.

For further monitoring, you might also want to explore complementary commands like du for folder sizes and lsblk for detailed block device info.

Did you enjoy this article? Feel free to share it on social media and subscribe to our newsletter so you never miss a post!

And if you'd like to go a step further in supporting us, you can treat us to a virtual coffee ☕️. Thank you for your support ❤️!
Buy Me a Coffee

Categorized in:

Tagged in:

,