I've got a web host (linux hosting) whose disk is almost completely full. How do I list out directories (and their subdirectories) by largest size to figure out where the biggest disk hogs are?
From a terminal:
Show disk free space (human readable)
Show sizes in the www-root
sudo du -sh /var/www/*
Apache log files
sudo du -sh /var/log/apache2/*
These would be my first few guesses (databases as well). Also, your applications may have log files as well, so keep that in mind. ie:
sudo du -sh /var/www/railsapp/current/logs/*
Hope this helps!
A command line I've found very useful in finding out what's filling my disk is
du -ak | sort -rn | less
This will list all the files and directories under the current directory in decreasing order of total disk space usage. The numbers before each line are in kilobytes.
For example, running this command in
/usr on my Ubuntu desktop produces output that starts like this:
7586900 . 3291420 ./share 2644256 ./lib 1093752 ./src 830268 ./share/doc 355520 ./bin 314976 ./lib/jvm 276240 ./share/fonts 272296 ./share/icons 247000 ./share/fonts/truetype 245196 ./share/doc/texlive-latex-extra-doc 242688 ./share/doc/texlive-latex-extra-doc/latex 230932 ./lib/openoffice 229560 ./lib/openoffice/basis3.2
From this output, I can notice for example that I have a lot of LaTeX documentation installed that I'm not really using. If I needed to free some disk space, that would seem like a good place to start.
Mind you, running this command can take a while if you have a lot of files. If you might want to keep the list around for a while, it may be a good idea to redirect it to a file instead of piping it directly to