Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Which sequence of commands will tell me which files are the largest starting from a particular directory, including all sub directories? I want to know where all the space went.

Preferably just with regular unix'y commands.

If possible, try to keep it compatible with Sun OS 5.10 (perhaps in addition to regular Linux answers, not as a replacement, to keep it as general as possible.)

share|improve this question

migrated from stackoverflow.com Jul 25 '09 at 0:49

This question came from our site for professional and enthusiast programmers.

    
There are two votes for SU and two for SF. Which is more appropriate? This could belong on either one, in my opinion. –  mmyers Jul 24 '09 at 18:09
5  
@mmyers: gave it to SU... SU needs Real Questions! –  Shog9 Jul 25 '09 at 0:50
    
But SU already has a very similar question! superuser.com/questions/9847/… –  Jonik Aug 4 '09 at 8:22
add comment

9 Answers

up vote 6 down vote accepted

I personally like to use du -sh * to see how big each directory is within the current directory.

share|improve this answer
    
This is actually really useful with a minor mod: du -s * | sort -nr. –  Alex Budovski May 8 '10 at 12:36
1  
You can keep the file sizes in human readable format with du -sh * | sort -hr. –  Jorge Israel Peña Apr 25 at 0:18
add comment

du . -ha | sort -nr

share|improve this answer
1  
I find the fact that you can pronounce that command highly entertaining. It sounds funny too. –  jtbandes Jul 25 '09 at 0:51
2  
-1, this is wrong. The "-h" in the the du command breaks the sorting. –  therefromhere Jul 26 '09 at 10:22
1  
It's not wrong, just not portable. -h is a GNUism. Use -k instead with Sun OS. –  Ludwig Weinzierl Aug 4 '09 at 8:20
add comment

basically you can use the du command. something like this

du -a /home | sort -rn |head -1

please look at the man page or info du for more options.

Or, you can use GNU find.

find /home/ -type f -printf "%s:%p\n" | sort -t":" -rn| head -1
share|improve this answer
    
Does 'find' on Sun OS 5.10 have an alternative I can use to -printf ? –  Alex Budovski Aug 4 '09 at 8:05
    
Also, is there any way I can get the first command (du ...) to filter out directories? I only am really interested in files, like with your second command. –  Alex Budovski Aug 4 '09 at 8:11
add comment
du -a | sort -n

would do the job. Using baobab (it's part of the gnome utils, so it's likely already installed on your system), you get a quite nice graphical breakdown of the used space.

share|improve this answer
    
Any reason to use -g instead of -n? "Use this option only if there is no alternative; it is much slower than --numeric-sort (-n) and it can lose information when converting to floating point. " gnu.org/software/coreutils/manual/html_node/… –  therefromhere Jul 26 '09 at 10:25
    
@therefromhere: I used the manpage, which isn't quite as verbose as the site you linked. I just picked the first option that worked for the particular case. But you're right; I have edited my anwser. Thanks! –  balpha Jul 27 '09 at 7:31
add comment

If you want a list output with nice gui and navigation options, install the moonlight commander (mc in most package managers), and check "show directory sizes" in the command menu.

share|improve this answer
add comment

If you're using a debian/ubuntu based distro there are a couple of GUIs available in the repositories, which you can find using synaptic, such as Disk Usage Analyzer.

share|improve this answer
add comment

Not command line but still unix'y: kdirstat

I use it to find out where all the space went and I like it much better than Disk Usage Analyzer (aka Baobab). It's one of the few KDE apps that is tolerated in my GNOME environment;-)

enter image description here

According to kdirstat.sourceforge.net it runs on Solaris.

While KDirStat is a KDE program, it runs fine on every X11 desktop, i.e., it runs on Linux, BSD, and lots of other Unix-type systems (Solaris, HP-UX, AIX, ...).

share|improve this answer
add comment

NCDU is just great : ncurses based, fast, simple, http://dev.yorhel.nl/ncdu

aptitude install ncdu
share|improve this answer
add comment

Philesight run from the commandline, and results in a PNG plus web server, so you can view it online.

I found it through this list of disk usage programs. Useful list of programs, in addition to ncdu (which is small, zippy, and command-line only) : http://www.makeuseof.com/tag/how-to-analyze-your-disk-usage-pattern-in-linux/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.