DEV Community

Cover image for Disk Space Awareness: df, du and What is Filling Up Your System
Sana Muhammad Sadiq
Sana Muhammad Sadiq

Posted on

Disk Space Awareness: df, du and What is Filling Up Your System

Introduction

I’m continuing my 30-day Linux challenge as part of my preparation for the RHCSA exam, and today’s topic might just be a lifesaver for system admins and everyday users alike: understanding disk space usage with df, du and how to find what’s clogging up your system.

Index

  1. Why Disk Space Awareness Matters
  2. What is df
  3. What is du
  4. Real Time Scenario
  5. Industrial Insight
  6. Recommendations
  7. Quick Summary

🧱 Why Disk Space Awareness Matters

Running out of disk space can silently break a system whether it's preventing new files from being written, blocking services or even crashing processes. Being proactive is key.

That’s where df and du come in, they give you a clear picture of what's full, why, and how to fix it.

🔍 What is df?

df (Disk Free) reports available and used disk space on file systems.

🔧 Syntax:

df -h
Enter fullscreen mode Exit fullscreen mode

Image description

✅ Example:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        40G   20G   18G  53% /
Enter fullscreen mode Exit fullscreen mode
  • -h: Human-readable format (MBs, GBs)
  • Quickly helps you know which partition is getting full

Pro Tip: Use df -Th to also show filesystem types like ext4, tmpfs, etc.

📦 What is du?

du (Disk Usage) shows how much space a directory or file consumes.

🔧 Syntax:

du -sh /path/to/folder
Enter fullscreen mode Exit fullscreen mode

✅ Example:

$ du -sh /var/log
1.2G    /var/log
Enter fullscreen mode Exit fullscreen mode

Image description

  • -s: Summary only (don’t dive into subfolders)
  • -h: Human-readable

🛠 Tip: Run du -sh * inside a directory to compare which folders are space hogs.

🧰 Real Time Scenario

You log into a server and see alerts about low disk space. You use:

df -h
Enter fullscreen mode Exit fullscreen mode

Image description

to check overall usage — /var is 90% full.

Then:

du -sh /var/*
Enter fullscreen mode Exit fullscreen mode

Image description

to locate the culprit — it’s /var/log.

Then:

sudo du -ah /var/log | sort -rh | head -n 10
Enter fullscreen mode Exit fullscreen mode

Image description

to find which specific log files are bloating. You clear old logs or rotate them. Problem solved.

🧠 Industrial Insight

In cloud deployments and containerized environments (like Docker), disk bloat is common. Backups, logs, caches — they add up silently. Keeping df and du in your toolbox can save hours of debugging.

🛡️ Recommendations

  • 🔁 Set up cron jobs to monitor disk usage weekly
  • 📉 Automate cleanup with logrotate
  • 🚀 Combine find, du and xargs to identify and clean files older than X days
  • 🧪 Always use -h in scripts that will be reviewed by humans

✨ Quick Summary

Command Purpose Best Option
df Check disk usage df -h or df -Th
du Folder/file size usage du -sh

Today was all about staying in control, disk space issues don’t wait. Now I know exactly what’s filling up my system and more importantly, how to clean it up before it becomes a problem.

Image description

I'd love to hear your thoughts, insights or experiences with Linux. Feel free to share and join the conversation [ Connect with me on LinkedIn www.linkedin.com/in/techwithsana ]💜

#30dayslinuxchallenge #redhat #networking #cloudcomputing #cloudengineer #cloudarchitect #cloud #RHCSA #RHCE #RHEL #WomeninTech #Technology

Top comments (0)