Command of the month: Do you du?

Submitted by Andrew on Sun, 03/03/2019 - 18:34

While I do like and use the GUI DiskUsageAnalyzer and the ncurses-based Ncdu to examine disk usage on Linux systems, there is something that feels good about getting back to basics and using command line tools like the du (disk usage) command once and a while. While there is no doubt that using the command line does require a little more effort and might even  necessitate an occasional trip to a man page, the simplicity and power of commands like the following appeal my inner minimalist:

du -h --max-depth=2 | sort -hr

This command (which lists and sorts disk usage of directories two levels down from the point of execution) not only returns information faster than any GUI tool can, but it is much easier to use in automated scripts or via cron to auto-generate reports and the like.