Find which specific directory is eating your disk space without the endless du loop
Disk & Filesystem Management (Du/Df/Lsblk/Fstrim)
Find which specific directory is eating your disk space without the endless du loop
🧩 The Challenge
You get that 3 AM alert that a partition is at 98 percent full, but running du -sh * just gives you a massive list of folders you have to manually drill into one by one. I’ve wasted hours doing that recursive dance while a production app was crashing because it couldn’t write temp files.
💡 The Fix
You can use the du command with a depth flag to show you exactly which top-level subdirectories are the hogs, saving you the headache of clicking through every single one. It gives you an instant view of the biggest offenders so you know exactly where to start clearing out garbage.
du -h --max-depth=1 /path/to/check | sort -h
⚙️ Why It Works
Adding the max-depth flag tells du to stop digging once it hits the first level of folders, and piping that through sort -h orders them from smallest to largest so the space eaters are always at the bottom of your screen.
🚀 Pro-Tip: Toss an alias for this into your .bashrc because you’ll need it again next week.
Linux Tips & Tricks | © ngelinux.com | 9/12/2026
