Install ncdu on Amazon Linux
ncdu is a really handy tool for sysadmins. It's an ncurses front-end to the standard du
command.
It makes troubleshooting disk space issues really easy. I find ncdu
to be much better than running du -h
all over the place (or writing your own script for this), trying to figure out where all those free GBs disappeared, especially on a server machine like an Amazon ec2 instance.
Here's some sample ncdu output from running it in the /home/ec2-user directory:
--- /home/ec2-user --------------------------
698.3MiB [ 48.5% ##########] /src
546.7MiB [ 38.0% ####### ] /test
56.5MiB [ 3.9% ] test_r
Like many other popular packages, it's non-trivial to install ncdu on Amazon Linux. There's no standard yum repository for it so unfortunately sudo yum install ncdu
won't work. It might be possible to install it via a Fedora repo, but I haven't tried this. Plus it's rather easy to build it from source.
I couldn't find a ready-made "HowTo" for thison Google/StackOverflow/etc, so here's a simple script that will painlessly install it for you on Amazon Linux (or CentOS or any RedHat-flavored Linux distro)
#!/bin/bash
# install packages/dependencies for compilation
sudo yum -y install gcc make ncurses-devel
cd /tmp
# the latest version of ncdu is published here: http://dev.yorhel.nl/ncdu
# update the link below if necessary:
wget -nv http://dev.yorhel.nl/download/ncdu-1.10.tar.gz
tar xvzf ncdu-1.10.tar.gz
cd ncdu-1.10
./configure --prefix=/usr
make
sudo make install