Find the biggest directories with du

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  
Avatar
Benjamin Cane
Principal Engineer, Vice President

Principal Engineer focused on building cloud-native software solutions for financial platforms. Benjamin uses both his systems and software knowledge to build end-to-end platforms. Platforms purpose built for performance, and resiliency.

Next
Previous

Related