Check the disk space consumption of a Linux directory

Today, one of my virtual systems ran out of disk space. To find the root cause I needed to find the directory that was filling up. Using the right parameters, the du command returns a list of directories and their disk space consumption.

du -hc --max-depth=0 /var

For example:

root@DB152:/# du -hc --max-depth 1 /var
704K    /var/tmp
4.0K    /var/mail
23M     /var/log
1.1M    /var/backups
4.0K    /var/local
3.2G    /var/lib
20K     /var/spool
734M    /var/cache
4.0K    /var/opt
3.9G    /var
3.9G    total

Removing files of a certain type recursively:

find . -name "*json.log" -type f -delete

Clearing (system) log files:

truncate /var/log/* --size 0