Find the largest files and folders on linux

The disk is full again. Here is how to find what is eating it.

SNP 021 #24B Filed cmd linux

Start from the top and work your way down. The biggest folders in the current directory:

shell
du -h --max-depth=1 | sort -rh | head -20

Then cd into the fattest one and run it again. Or skip the detective work and list the biggest files on the whole disk:

shell
sudo find / -xdev -type f -size +500M -exec ls -lh {} + 2>/dev/null | sort -k5 -rh | head

-xdev keeps it on one filesystem, so it doesn't wander into /proc or mounted shares.

The usual suspects are /var/log, old journal files (journalctl --disk-usage) and Docker (docker system df).