Find the biggest directories with du

Written by Benjamin Cane on 2011-08-14

If you ever need to find what directory is using up all of your filesystem space du is here to save the day.

Example:

[[email protected] ~]$ du -k  
148 ./.pulse  
4 ./.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}  
8 ./.mozilla/extensions  
4 ./.mozilla/firefox/lbtgx82r.default/extensions  
44 ./.mozilla/firefox/lbtgx82r.default/bookmarkbackups  
4 ./.mozilla/firefox/lbtgx82r.default/minidumps  
288 ./.mozilla/firefox/lbtgx82r.default/Cache  
12 ./.mozilla/firefox/lbtgx82r.default/chrome  
46776 ./.mozilla/firefox/lbtgx82r.default  
8 ./.mozilla/firefox/Crash Reports

As you can see by the output du is ordered by filename, if you want to order it by size of the file you can use sort.

Example:

[[email protected] ~]$ du -k | sort -nrk 1  
58864 .  
46808 ./.mozilla  
46792 ./.mozilla/firefox  
46776 ./.mozilla/firefox/lbtgx82r.default  
5920 ./Downloads  
516 ./.gstreamer-0.10  
320 ./.gconf  
288 ./.mozilla/firefox/lbtgx82r.default/Cache  
256 ./.gconf/apps  
168 ./.local  
164 ./.local/share  

Picture of Benjamin Cane

Benjamin's specialty is keeping the lights on for mission critical systems. He is currently building applications that enable high concurrency financial transactions.

Recently Benjamin published his first book; Red Hat Enterprise Linux Troubleshooting Guide. In addition to writing, he has several Open Source projects focused on making Ops easier. These projects include Automatron, a project enabling auto-healing infrastructure for the masses.


Publications

Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Excellent, excellent resource for practical guidance on how to troubleshoot a wide variety of problems on Red Hat Linux. I particularly enjoyed how the author made sure to provide solid background and practical examples. I have a lot of experience on Red Hat but still came away with some great practical tools to add to my toolkit. - Amazon Review