Ncdu - Ncurses du
Ncdu is a command line tool to view and analyse disk space usage on linux. It can drill down into directories and report space used by individual directories. This way it is very easy to track down space consuming files/directories. It actually allows the user to do this much faster than even a gui file manager. On the server ofcourse gui tools are not present.
Just start from the root directory, or the web directory as the case may be and descend down following the directories that are reported to by ncdu to be bloated.
Ncdu vs du/df
The interface of ncdu is built using ncurses and is interactive. Ncdu is different from df or du.
Ncdu just does the one task of reporting the space used by a directory and drill down. On the other hand the df command reports space used by different storage devices.
The du command is more of raw in nature and reports space used by individual files and recursively into sub directories. Due to this the output is huge and very cumbersome. The du command needs to be passed few options and combined with other commands via pipes to produce something readable.
The ncdu project site is located at
Here is why the author invented ncdu
Not quite happy with the available disk usage analyzers and looking for a fun project to get used to C programming, I started working on ncdu: A disk usage analyzer with an ncurses interface, aimed to be run on a remote server where you don't have an entire gaphical setup, but have to do with a simple SSH connection. ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.
Install it on ubuntu with the apt-get command
$ sudo apt-get install ncdu
Start it by running ncdu.
ncdu 1.9 ~ Use the arrow keys to navigate, press ? for help --- /home/enlightened ---------------------------------------------------------------------- 2.0GiB [##########] /.android 636.0MiB [### ] /.cache 342.3MiB [# ] CentOS-6.4-x86_64-minimal.iso 178.2MiB [ ] /.config 171.3MiB [ ] /.local 74.1MiB [ ] /.jdownloader 70.0MiB [ ] /.kde 32.8MiB [ ] /.dropbox-dist 19.6MiB [ ] /.mozilla 9.8MiB [ ] /.dropbox 8.9MiB [ ] /.purple 6.4MiB [ ] /.softmaker 5.0MiB [ ] /SoftMaker 4.5MiB [ ] /.thumbnails 3.2MiB [ ] /.skype.omikrosys 3.0MiB [ ] /Desktop 2.8MiB [ ] car_phone.zip 2.5MiB [ ] /Pictures 1.9MiB [ ] /.skype.silver 1.6MiB [ ] .xsession-errors.old Total disk usage: 3.5GiB Apparent size: 3.5GiB Items: 17268
All files and directories are listed sorted in descending order by their size. The middle column is a bar to indicate the relative size. The bar that is full, is the largest.
Press the right arrow key on any directory to navigate inside the directory further and check which file or directory is using how much space. This is quite handy when analysing disk space usage on a remote server over ssh.
Press the left key to go back to the parent directory. Easy to use!!
So lets take for example, if your un-attended mailbox has grown huge in size and the server is sending out disk space alarms, then fireup ncdu and get down to the right directory and do a rm *. Very handy! This makes ncdu a very essential tool for sys admins.
ncdu by default updates the screen and data multiple times every second. On a remote connection this is not desirable since it would waste bandwidth and slow down the output. Use to "-q" option to fix this
Quiet mode. While scanning or importing the directory, ncdu will update the screen 10 times a second by default, this will be decreased to once every 2 seconds in quiet mode. Use this feature to save bandwidth over remote connections. This option has no effect when "-0" is used.
$ ncdu -q
Omit mounted directories
Ncdu by default would try to scan all directories existing in a path. However some directories might mounted devices which should not be scanned for checking space usage. Use the "x" option to omit such directories
-x Do not cross filesystem boundaries, i.e. only count files and directories on the same filesystem as the directory being scanned.
$ ncdu -q -x
So ncdu is a powerful tool to monitor, check and analyse disk space usage on your linux system. To monitor other resources like cpu, ram, disk io etc use htop, iotop and the likes.