How to Clean the Disk with ncdu

What is ncdu

When it comes to cleaning disk space, you may find the du utility useful, but slow. Then ncdu comes to save the day as user-friendly version of du.

ncdu takes a directory as argument, to analyze the files inside and provide information to the user about the amount of space required by each file or subdirectory. This way, the user can navigate through the analyzed directory and start deleting files or whole directories as needed.

Install ncdu

On Ubuntu systems:

sudo apt install ncdu

On Mac:

brew install ncdu

Use ncdu

To run ncdu, just pass the directory you want to analyze:

ncdu <MYDIR>

After this, you can navigate through the directories either using vim movements (jklh) or the arrow keys (down, up, left, right). You can get help from the utility by pressing ?.

            ┌───ncdu help─────────────────1:Keys───2:Format───3:About──┐
            │                                                          │
            │       up, k  Move cursor up                              │
            │     down, j  Move cursor down                            │
            │ right/enter  Open selected directory                     │
            │  left, <, h  Open parent directory                       │
            │           n  Sort by name (ascending/descending)         │
            │           s  Sort by size (ascending/descending)         │
            │           C  Sort by items (ascending/descending)        │
            │           M  Sort by mtime (-e flag)                     │
            │           d  Delete selected file or directory           │
            │           t  Toggle dirs before files when sorting       │
            │                        -- more --                        │
            │                                         Press q to close │
            └──────────────────────────────────────────────────────────┘

While you navigate through the directory contents, the tool will show the size of each file and subdirectory. At any moment, you can delete the file or directory by pressing d.

The following gif shows the process of starting the tool, moving through the directories and deleting files.

 
ncdu usage


For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.