Find the biggest directories with du

Written by Benjamin Cane on 2011-08-14 20:30:05

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 is a Systems Architect working in the financial services industry focused on platforms that require Continuous Availability. He has been working with Linux and Unix for over 10 years now and has recently published his first book; Red Hat Enterprise Linux Troubleshooting Guide.

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

Sponsored by