Show disk usage in descending order

  Linux, Macintosh

If you need to find the amount of disk space being consumed in Linux, you can show it recursively through your directories as follows.

$ sudo du -ahx /var | sort -rh | head -10
357M /var
250M /var/lib
185M /var/lib/rpm
177M /var/lib/rpm/Packages
79M /var/cache/dnf
79M /var/cache
34M /var/lib/sss
29M /var/log
27M /var/lib/sss/mc
27M /var/lib/selinux/targeted/active

Mac/Unix systems can use the following command.

% sudo du -sk /Volumes/HD2/Installers/* | sort -rn | head -10
69298256 /Volumes/HD2/Installers/ISO
602508 /Volumes/HD2/Installers/Adobe-DNG-Converter
405012 /Volumes/HD2/Installers/VMware vSphere Hypervisor ESXi 7.0U3d
81728 /Volumes/HD2/Installers/Keychron-keyboard
68540 /Volumes/HD2/Installers/Luminar
59848 /Volumes/HD2/Installers/Iperius-Backup
55888 /Volumes/HD2/Installers/iStat
42424 /Volumes/HD2/Installers/WP-Dupe
24048 /Volumes/HD2/Installers/
156 /Volumes/HD2/Installers/Bandwidth-Tester

These commands will show the disk usage in order, highest amount of space first in the directory specified.