Finding files that use the most disk space
With standard available tools:
To list the top 10 largest files from the current directory:
du . | sort -nr | head -n10
To list the largest directories from the current directory:
du -s * | sort -nr | head -n10
UPDATE These days I usually use a more readable form (as Jay Chakra explains in another answer and leave off the
| head -n10, simply let it scroll off the screen. The last line has the largest file or directory (tree).
Sometimes, eg. when you have lots of mount points in the current directory, instead of using
-x or multiple
--exclude=PATTERN, it is handier to mount the filesystem on an unused mount point (often
/mnt) and work from there.
Mind you that when working with large (NFS) volumes, you can cause a substantial load on the storage backend (filer) when running
du over lots of (sub)directories. In that case it is better to consider setting
quota on the volume.
Adding to jippie's answer
To list the largest directories from the current directory in human readable format:
du -sh * | sort -hr | head -n10
[~]$ du -sh * | sort -hr | head -n10 48M app 11M lib 6.7M Vendor 1.1M composer.phar 488K phpcs.phar 488K phpcbf.phar 72K doc 16K nbproject 8.0K composer.lock 4.0K README.md
It makes it more convenient to read :)
ncdu, as it can give you an overview of disk usage. From its website:
A disk usage analyzer with an ncurses interface, aimed to be run on a remote server where you don't have an entire gaphical setup, but have to do with a simple SSH connection. ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.