Getting disk space usage from the command line is simple. The df command shows disk usage per filesystem. The du command shows disk usage for files, directories and subdirectories. This is great for simple things, however, doing an in-depth analysis is easier using some graphical tools.

This site has a very comprehensive list of tools available for use on your desktop. Professional tools are also available, but let's keep it simple.

The 10 Best Disk Analyzer Tools for Linux System in 2020

Dealing with Multiple Filesystems and Directories

If you are using some of the basic tools, it is necessary to understand that all files live under "root", which is the "/" are the beginning of all full paths to files. This includes mounted file systems and special device files. It is tempting to use this command to get a summary of the top level directories on Linux:

$ sudo -i
# du -sh /*

This will attempt to get disk usage on all mounted filesystems and directories that do not have regular files, like "/dev". Running du on a mounted USB drive can be maddeningly slow. So, what to do?

Disk filesystems are composed of blocks of data "mounted" on a directory. This provides a "handle" to the device where it's filesystem is kept. The mount command tells you which block devices are, but it includes a bunch of "junk" you don't really want to see. df provides a nicer list because it only shows directories that actually contain files.

If you really just want filesystems, you can take advantage of the fact that filesystems are always block devices under "/dev". mount | grep ^/dev will do the trick.

Speeding Up Creating Summaries

Now that you know how to use du -s you'll notice it is still very slow. Let's say you find a big file after waiting 60+ seconds for du -s to complete, remove it, then run du -s again. Wait another 60+ seconds, and repeat for while. This takes a long time. You'll need to use more sophisticated tools. Let's stay with using the command line. This article has a pretty good explaination of how to deal with performance:

How to cache or otherwise speed up `du` summaries?
We have a large file system on which a full du (disk usage) summary takes over two minutes. I’d like to find a way to speed up a disk usage summary for arbitrary directories on that file system. For


I looked at ncdu. Although this is a nice program, it is very basic. If you wnat to try it, it's a simple install:

$ sudo apt install ncdu


I'm used to using DaisyDisk for the Mac and Windirstat on Windows. duc is a almost as efficient as these tools, but it can also be used on the command line with "curses" graphics. Which is very cool. It also keeps a database of the scan it performs. This works out very well. It's a simple install, but not quite obvious:

$ sudo apt install duc-nox

This installs the duc-nox command, which is "curses" based. I've not looked for the duc command yet. I'm going to try using duc-nox for a while to see how well it performs.

Mac OS

I like to use the command line a lot. duc can be installed on Mac OS. This script has a basic procedure, which doesn't quite work for me yet.

how to install duc on mac using brew
how to install duc on mac using brew. GitHub Gist: instantly share code, notes, and snippets.