Sunday, November 6, 2011

NCDU - The Answer to a Question

The question is:

Where did all my disc space go?

The answer? An ncurses based application called NCDU. NCDU is a simple, light-weight disc-usage analyzer. I like NCDU because of it's few dependencies, in fact installing in on my system took less than 1mb worth of additional space. It is fast, because like all good applications it is written entirely in C. 

To install NCDU on a Debian based system simply run:

sudo apt-get install ncdu

Then launch NCDU with:

ncdu /

Depending on how much space is taken up (and how fast your drives are) you will have to wait a moment while it indexes your files. After a few moments you will be greeted with a screen that looks something along the lines of:

Because this is an ncurses based application it does mean you have to use the keyboard to make your way around - not a mouse. The keys are fairly intuitive though and there is a handy dandy help screen should you need it:

Should you find a file/folder you no longer need while browsing with NCDU you can even delete it on the spot (just because doing this if you are in the / directory). Hopefully you will find this application as useful as I did when a stray log file gets far too large :)

~Jeff Hoogland


  1. Good tip Jeff! I've been using combos of du and df to watch and, when needed, free up space. A bit laborius, to say the least. ncdu is just the ticket to make it easy and fast.


  2. Running this command:

    du -shm `ls` | sort -g

    will list the size of all subdirectories in the current directory in megabytes sorted smallest to largest.

  3. This will provided an output similar to ncdu, but is more accurate, in terms of sorting by size:

    du -sbh $(find . -maxdepth 1 ! -name '.' -exec du -sb {} \;|sort -nr|awk '{print $2}')

  4. I just installed it and i have to say its great.I just got 5 gb back on my first glance.Very good piece of software.Thanks for sharing dude you rock. :)