Disk usage on subdirectories on Linux are not entirely easy to see and you have to use the
du command to see how much space is being used further down. One caveat with
du is that it can take really long on large file systems if run close to the root directory. So be careful!
du command to see disk usage on a Linux machine is the following:
du -h --max-depth=1
-h means human readable format and the
max-depth parameter will show values one level deep.
You could also just do
du --summarize to see a summary.
But what do you do when you want this sorted?
How to output disk usage sorted by size
Warning: This command is a mess on a big server, it takes very long and if you have a slow disk the entire machine will have performance problems. rather do du without the -h and copy/paste into a Google Sheet and sort that way.
Use the following command to sort disk usage by size in the current directory:
sudo du -ks $(ls -d */) | sort -nr | cut -f2 | xargs -d '\n' du -sh 2> /dev/null