NCDU-fu

Sometimes it feels good to have some meager sysadmin competencies, such as knowing how to quickly identity where large files are in a particular hosting account. This issue comes up from time-to-time when someone discovers all their storage space has been eaten up, but they are not sure where and why.  Often this is a symptom of a larger problem, such as an error_log run out of control which suggests bad process for a particular application, etc. That was the case on a ticket this morning, and luckily I knew the NCDU command. What is NCDU, you ask?

Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don’t have an entire graphical setup available, but it is a useful tool even on regular desktop systems. 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.

In other words, a script for a remote server that finds big files. You can install it on your server, and then run it by navigating in command line to the offending account, which on our cPanel servers would live at /home/offendingaccount and running the command NCDU. After that, it will list all the directories and their sizes, followed by files.  You can then locate the directory with the largest file usage, and then change to that directory and run NCDU again until you find the offending file. In the example this morning, it was a 6 GB error_log in a directory running WordPress, easy fix to clean out space, and a good heads up things in that account need to be checked for a bad plugins, theme, etc.

The life of a Reclaimer is always intense

This entry was posted in reclaim, sysadmin and tagged , , , . Bookmark the permalink.

4 Responses to NCDU-fu

  1. Dude. That’s awesome. Works great on my mac, too, after ‘brew install ncdu’. Holy huge files, batman!

  2. I hope you’re able to catch Mr. Robot from Italy. Have you watched the show? Apparently the sysadmin/hacker use of the command line is fairly accurate throughout the show. The über hacker Elliot is of course spiting out ridiculous network skills, but the language and text is fun to try to understand. Do you feel like you’ve gained a hacker superpower every time you’ve figured out something like this?

    *** Also I feel like a comparison between Videodrome and the show’s F-Society hacker collective would be interesting.

    • Reverend says:

      I’m anything but a hacker, but I am more comfortable navigating a cPanel server 🙂 I do really like learning it though, it is slow going, but it’s funny how that creeps up on you.

      I have not seen Mr. Robot yet, but that is now on my list, so thanks Michael!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.