du
Find out how much space a folder takes
What it does
du (disk usage) adds up the size of files and folders. With no flags it prints every folder inside, so you almost always type -sh: -s for one line with the total, -h for readable units.
du -sh * shows the size of each item in the current folder, and with | sort -h sorts them from smallest to largest, so the heaviest end up at the bottom. * skips hidden files. System folders need sudo, or some files are not counted.
Syntax
du -sh <folder>
du -sh * | sort -hExamples
Find out how big the folder /var/log is
du -sh /var/logsame as:
du -hs /var/log,du -s -h /var/log,du -h -s /var/logdu— disk usage — how much it takes-s— a single line with the total-h— in readable units/var/log— the folder
Show the size of every file and folder here, smallest to largest
du -sh * | sort -hsame as:
du -hs * | sort -hdu -sh *— a total for each item in the folder| sort -h— sort by size, K, M and G included