Find the real disk space hogs, fast

Disk & Filesystem Management (Du/Df/Lsblk/Fstrim)

Find the real disk space hogs, fast

🧩 The Challenge

You’re staring at a “disk full” alert, `df -h` is screaming that `/var` is stuffed, but when you `cd /var` and run `du -sh *`, you only see the immediate top-level directories. Digging down manually by repeatedly running `du -sh` on each big directory takes forever, and you just know the biggest offender is buried five layers deep somewhere.

💡 The Fix

Don’t spend an hour manually traversing your filesystem. There’s a quick command combo that’ll show you the top N biggest directories and their total sizes, no matter how deep they’re nested. You’ll pinpoint those runaway log directories or forgotten ISOs in seconds.

find /var -xdev -type d -print0 2>/dev/null | xargs -0 du -sch 2>/dev/null | sort -rh | head -n 15

⚙️ Why It Works

This chain first finds every directory under `/var`, sticking to one filesystem with `-xdev`. Then, `xargs` runs `du -sch` on each one, summing up its total contents. Finally, `sort -rh` orders them by human-readable size, largest first, and `head` shows just the top few.

🚀 Pro-Tip: Use `tail -n +2` before `head` to skip the root directory’s total.

Linux Tips & Tricks | © ngelinux.com | 10/28/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted