Ncdu - a CLI disk usage analyzer

Yesterday I tested ncdu, a terminal program to show disk usagage. I noticed, that it is very easy to delete directories there (accidentially) by pressing key d, especially when ncdu is launched with sudo rights to show files where normal users have no access to.

To launch the program in read-only mode and without the delete option, you can launch it with the -r option, e.g.

ncdu / -r

The files/directories are not moved to trash by pressing d to delete, but permanently deleted (you are asked if you really want to delete the file), so this is a bit safer if you just want to check the disk usage.

2 Likes

That looks like an accident likely to happen. Especially if the disgruntled cat walks across the keyboard.

3 Likes

Or a tiger, I love big cats :smiley:

2 Likes

Another useful option is -x: it keeps ncdu on the same filesystem, so a scan of / won't descend into other mounted filesystems. Running as root can also reveal files a normal user can't read, so the totals may differ.