My disk is 95% full but I don't know what's eating the space. How do I find out?

Quick Linux Tip #31:

Try: sudo du -h -d 1 / 2>/dev/null | sort -rh | head -10

Info: du -h -d 1 scans top-level directory sizes. sort -rh ranks the largest directories first, and 2>/dev/null silences permission errors.

Examples:

  • $ sudo du -h -d 2 /var | sort -rh | head -20
  • $ ncdu /  # Interactive disk usage explorer (install: apt install ncdu)
  • $ sudo du -sh /var/log/*.log | sort -rh | head

Note: Drill down step by step: start at /, then dive into the biggest directory. ncdu is a useful interactive alternative for browsing disk usage.




LinuxTeck.com
linuxteck@ubuntu:~$ sudo du -h -d 1 / 2>/dev/null | sort -rh | head -10
45G     /
23G     /var
12G     /home
5.6G    /usr
2.3G    /opt
1.2G    /tmp
456M    /root
234M    /boot
123M    /etc
89M     /lib
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #30: How do I tail a log file with colored output for errors? NEXT ARTICLE Quick Linux Tip #32: How do I see everything a specific user is doing right now?
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.