Linux Fix Storage Issues By Finding Large Files and Directories

Ask Ubuntu | Dan King

du -aBM 2>/dev/null | sort -nr | head -n 50 | more

du arguments:

sort arguments:

head arguments:

Note: Prefix with sudo to include directories that your account does not have permission to access.

Example showing top 10 biggest files and directories in /var (including grand total).

cd /var
sudo du -aBM 2>/dev/null | sort -nr | head -n 10
7555M   .
6794M   ./lib
5902M   ./lib/mysql
3987M   ./lib/mysql/my_database_dir
1825M   ./lib/mysql/my_database_dir/a_big_table.ibd
997M    ./lib/mysql/my_database_dir/another_big_table.ibd
657M    ./log
629M    ./log/apache2
587M    ./log/apache2/ssl_access.log
273M    ./cache

Benjamin Rancourt

sudo du --all / | sort --numeric-sort --reverse | head --lines 15

Shorthand

sudo du -a / | sort -n -r | head -n 15

specify a directory

sudo du -a /var/log | sort -n -r | head -n 15

Credits