Sep 08, 2016 Tag: Linux

Investigate Disk Usage With ‘ncdu’

And: How to install on shared hosting

Today I was to install something for a customer in his shared hosting account. What was eating up most of the available disk space? ncdu is a phantastic tool on the commandline to answer that. Only: It wasn’t available. So I tried to install it as a regular user - and succeeded! Thank you jweiland for fullfilling the requirements for that. And this is what I did.

Updated on Sep 09, 2016

Welcome ncdu

This is ncdu. You can easily and interactively investigate which files are consuming what disk space on the commandline:

Using ncdu

Installation Steps For Non-Admins

  1. Is it already available?

    $ ncdu
    bash: ncdu: command not found
    

    No, it isn’t. So let’s install it as a regular user.

  2. Go to your home directory:

    $ cd
    
  3. Visit ncdu’s homepage and find out about the latest source package. Currently it is 1.12. Download the source package:

    $ wget https://dev.yorhel.nl/download/ncdu-1.12.tar.gz
    
  4. Unpack:

    $ tar xzf ncdu-1.12.tar.gz
    
  5. Enter the source folder:

    $ cd ncdu-1.12/
    
  6. The next step is to run ‘configure’ to create a ‘Makefile’. Since we are a regular user we use the prefix parameter to tell configure to use our home folder as base for the usual subfolders like ‘bin/’ and ‘lib/’:

    $ ./configure --prefix=$HOME
    
  7. Now build the binary:

    $ make
    
  8. And install:

    $ make install
    
  9. Verify: The executable should now be in $HOME/bin:

    $ ls -la $HOME/bin
    

    Repeat this step whenever you start a new shell.

  10. And start using ncdu:

    $ ncdu
    bash: ncdu: command not found
    
  11. Oops, what’s that? Look at your path:

    $ echo $PATH
    /usr/bin:/bin:/usr/sbin:/sbin
    
  12. Aha, our private bin/ folder is not in the path. So let’s change this:

    $ PATH=$PATH:$HOME/bin
    
  13. And again: Start using ‘ncdu’:

    $ ncdu
    

    Yeah, victory! See the screenshot above.

  14. If you want to have your $HOME/bin path included always automatically - try using ‘.bashrc’ file. Works like a charm in my case at jweiland. Thank you Jochen for the tip:

    # go home
    cd
    
    # new line
    echo >> .bashrc
    
    # the important line
    echo export PATH=$PATH:$HOME/bin >> .bashrc
    

Published under the CC-BY License

Previous topic

Upgrade to Python 2.7.11 on Ubuntu 14.04 LTS

Next topic

Take Huge And Giant Screenshots

Tags

Archives

Languages

Recent Posts

This Page