How to Use the df (Disk Free) Command in Linux

Written by

in

A Beginner’s Guide to Checking Linux Storage with df (Disk Free)

Running out of disk space on a Linux system can cause applications to crash, updates to fail, and the system to slow down. One of the most essential and reliable tools for monitoring your storage is the df command, which stands for “disk free.” This guide will teach you how to use this powerful command to check your Linux storage effectively. What is the df Command?

The df command is a pre-installed utility in almost every Linux distribution. It inspects your file systems and reports the amount of available and used disk space. By default, it displays this information in 1-kilobyte blocks, which can be difficult to read. Fortunately, a few simple modifiers can make the data clear and actionable. How to Run the df Command

To use df, open your terminal and type the command followed by any options you need. 1. The Standard Command

If you run the command without any options, you will see a raw breakdown of your storage: df Use code with caution.

This outputs columns for the file system name, total blocks, used space, available space, use percentage, and the directory where the storage is mounted. 2. View in Human-Readable Format

Because counting kilobytes is impractical, you can add the -h flag. This converts the output into gigabytes (G) and megabytes (M), making it easy to read at a glance: df -h Use code with caution. 3. Check a Specific Directory

If you want to know the storage status of a specific drive or directory rather than the entire system, pass the directory path as an argument: df -h /home Use code with caution. 4. Display File System Types

Linux uses various file system types like ext4, xfs, or tmpfs. To see which file system each partition uses, add the -T flag: df -hT Use code with caution. Understanding the Output Columns

When you run df -h, the terminal displays a table with six main columns:

Filesystem: The name of the physical storage partition or virtual drive.

Size: The total storage capacity of that specific file system.

Used: The amount of space currently occupied by your data and system files. Avail: The remaining space available for new files. Use%: The percentage of total space currently being used.

Mounted on: The specific directory (mount point) where the file system is accessible in your Linux environment. Pro-Tip: Filtering Out Virtual File Systems

Modern Linux distributions utilize many temporary, memory-based file systems called tmpfs. These can clutter your screen when you only want to see your actual hard drives or solid-state drives.

To filter your results and only show real, physical file systems (like ext4), use the -t flag followed by the file system type: df -h -t ext4 Use code with caution.

Alternatively, you can exclude tmpfs entirely using the -x flag: df -h -x tmpfs Use code with caution.

Mastering the df command takes only a few minutes, but it provides peace of mind and total control over your Linux storage environment. Keep these flags handy the next time you need to audit your system health.

If you want to dive deeper into managing your Linux storage, please tell me if you would like to: Learn the du (disk usage) command to find large files. Clean up hidden system logs to free up space. Format and mount a new drive via the terminal.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *