Errors about disks being full is always a pain. With normal use of the system, you never know what takes up the most space, which you must if you want to clean up your system efficiently.

Unfortunately there's no command to locate your largest files or directories on a Linux system. Though piping a few commands can easily help you get the list of files and directories you want.

- du : Checking size on files or directories
- sort : Sorting lines of given data
- head : Limit output to the first part of the original output

So this is what you can enter if you want to know the top 10 of the largest files and / or directories on your Linux system. Du checks size (-a for all files and dirs), sort sorts the data it receives from du (-n for numeric sorting, -r for reversing the sort), and throws it at head, which takes the top 10 and shows it.
du -a /var | sort -n -r | head -n 10

Results on my system are the following:
689180 /var/www

347840 /var/www/codebase

347752 /var/www/codebase/modules

347636 /var/www/codebase/modules/phplib

347456 /var/www/codebase/modules/phplib/projects

269804 /var/lib

79076 /var/www/msgboard

72872 /var/lib/dpkg

67840 /var/lib/gconf

63360 /var/www/tim

React on this article

Enter the code here: