167 comments

[ 2.7 ms ] story [ 224 ms ] thread
This tool has been pretty invaluable to me over the years in diagnosing/tracing high disk usage, particularly relevant for pypi and npm packages that were needlessly shipping huge artifacts.
This program is extremely useful. I have recently performed a recovery on a bricked Microsoft Surface and was able to extract all the useful files from a Windows home directory and quickly discard all the libraries, caches, and so on. By seeing the folders that take up the most space you can easily determine what the juicy bits in a folder hierarchy are. Huge time saver.

Using GrandPerspective on macOS was a similar revelation, but ncdu being keyboard driven and allowing you to quickly launch a shell inside each folder and then apply find -exec there quickly is a productivity boost on yet another level.

Love ncdu. I probably use it at least once a week somewhere debugging a disk that's getting full.
If you use a Btrfs filesystem with snapshots, I can recommend Btdu as an alternative. Advantage: Can handle duplicate files (snapshots), which however only occupy 1x disk space.

https://github.com/CyberShadow/btdu

Have used btdu - very useful on Btrfs systems with lots of snapshots.
At first blush, this beats the tar out of using other deduplicator strategies on btrfs. I'm looking forward to checking this out more thoroughly.
This looks very useful! I wish there were something similar for ZFS.
More interesting than its support of Btrfs features is its unusual statistical approach:

> btdu is a sampling disk usage profiler […] Pick a random point on the disk then find what is located at that point […] btdu starts showing results instantly. Though wildly inaccurate at first, they become progressively more accurate the longer btdu is allowed to run.

I never knew about this tool, but it looks quite useful--much better than just using df.

The only thing I wish it had was a squarified treemap view of disk space. There was an old graphical tool for Windows called SequoiaView that I used to use years ago, and I've never found a worthy replacement for it on Linux or MacOS.

sequoiaview looks like a clone of kdirstat, which is available on all platforms.
GrandPerspective is in the mac app store and at least for my needs was similar enough to SequoiaView.
Such a great tool. Thank you!

On a Mac, I've been using OmniDiskSweeper for years, but this can be run in a single directory and on my Linux machines as well. Fantastic!

And look, it didn't ask me to sign up for an account, and it didn't require me to consent to usage data collection with a huge Privacy Policy attached! How is that possible? (still dealing with this morning's scars from trying, and failing to run the warp terminal)

now if it was just an executable file and didn't require a package manager or compiling to install it would be flawless.
Nice GUI to `du -h --max-depth=1 .` or `du --max-depth=1 . | sort -n -r`
The other big advantage over just being a gui is that it Scans the filesystem ahead of time and keeps the data across your navigation into directories.

du will have to rescan as you traverse down the tree

The subsequent scans feel a lot faster, I suspect due to caching.
Nice tool - although with remote machines my go-to tool is KDE filelight, the joy of remote X11.
ncdu is fabulous. I used it a while back on my 2009 Mac mini and recovered 40GB of disk space. 8GB of this was in just four folders: ~/Library/Logs/CrashReporter/MobileDevice, /private/var/db/systemstats, /System/Library/Caches/com.apple.coresymbolicationd, and /Library/Caches/com.apple.iconservices.store.
I would advise against deleting random things on your disk that are taking up space.
If you like ncdu, you might also like dua[0]. You can run `dua i` to get an interface similar to ncdu, and can also run `dua` to list file sizes in the current directory, similar to `du`. Or `dua filename` to get the size of a given file.

[0] https://github.com/Byron/dua-cli

The UI is not as good but it’s multi threaded and much faster.
Not in any repo, I'll pass, thanks
Actually it is in the arch community repositories and seems to be quiet a bit faster than ncdu so I will keep it in my toolbox for now.

Painpoints are that there seems to be no progress bar in interactive mode, the ui is (imho) ugly/unintuitive (for instance the usage bar seems to be relative? and the shortcuts look like glyphs) and there are functions missing (like exclude patterns, you can exclude dirs though!).

So it won't replace ncdu, but if it get a interactive progressbar maybe it will be on all my machines (with arch)

Diistinctly not true. `nix run github:nixos/nixpkgs/nixos-unstable#dua`
it's in the void and arch repos
/usr/ports/sysutils/dua-cli
Best tool I've ever used for finding where I could free up some disk space
Interesting. I’ve just used df-m | sort -n and walked the tree from the CLI for so long.

I’ve also used windirstat (I think that’s what it was called) years ago on Windows and Disk Inventory X on MacOS graphically.

This seems like a nice in between that could replace both methods for me. I’ll have to try.

The GUI bunch of squares is really only useful when you can hover with a mouse and would be clunky in a TUI even if you could render it. And the FS structure isn’t immediately obvious, so I find myself wasting time wandering hovering over big files and globs of little ones.

I really like to avoid a mouse when I can unless it’s really useful.

FYI I recently discovered sort —-human is a thing so you can keep the K/M/G units if you want to.

However I use ncdu all the time.

Yeah, my habits come from using GNU, BSD, SysV and having to use the lowest common denominator.
You mean `du` right?
I always used "du -S | sort -n" ... I think... it's been a long time since I've needed to worry about disk space.
Yes, just dumb fingers typing the comment. :(
> I’ve also used windirstat (I think that’s what it was called) years ago on Windows and Disk Inventory X on MacOS graphically.

On Windows, the new hotness is WizTree, which rather than recursively calling directory listing functions, it directly reads and parses the file tables itself. This makes it orders of magnitude faster. I have a 2 TB hard drive full of a million files, and WizTree reads and parses it all in under a minute, whereas I can expect WinDirStat to take half an hour.

That's pretty brilliant.

My windows experience is really out of date. I knew NT4 and 2000 the best. Then I picked up 2008 for a while supporting small businesses. I don't hate it or anything, but am definitely deeper on Unixes and about equal on VMS that I supported as my NT4/2000 time. I'll work on whatever pays :).

I use ncdu almost daily across many different systems. Especially handy when running macOS on a <512GB volume and you need to keep an eye on ballooning caches and other "helpful" cruft.

`rmlint` and `jdupes` are also seeing a lot of use here lately, reclaiming terabytes of space from years of sloppy media organization (or the lack thereof!)

Yeah I prune stuff with ncdu weekly on my work 0.5T machine. Oddly I don’t have to use it so much on my 2T personal machine.
The best tool I've used on Windows for that is "Scanner" by Steffen Gerlach:

http://www.steffengerlach.de/freeware/

I find myself using WinDirStat on Windows systems, but often use ncdu in WSL.
On Windows, you should switch to WizTree. Rather than recursively calling directory listing functions, it directly reads and parses the file tables itself. This makes it orders of magnitude faster. I have a 2 TB hard drive full of a million files, and WizTree reads and parses it all in under a minute, whereas I can expect WinDirStat to take half an hour.

On an SSD, WizTree only takes a couple seconds.

For all the hate NTFS gets, MFT has led to the creation to two amazing tools: Everything and WizTree. Unfortunately both proprietary although freeware.
You should try Directory Report on Windows. It is faster than WinDirStat. Has more filtering and reporting than WinDirStat. Can find duplicate files too
I use WinDirStat on Windows

https://windirstat.net/

You should switch to WizTree. Rather than recursively calling directory listing functions, it directly reads and parses the file tables itself. This makes it orders of magnitude faster. I have a 2 TB hard drive full of a million files, and WizTree reads and parses it all in under a minute, whereas I can expect WinDirStat to take half an hour.

On an SSD, WizTree only takes a couple seconds.

`dua`, discussed elsewhere in this thread also works on windows, just for another option.
If someone could make a CLI DaisyDisk that would be amazing. If anyone's aware of it let me know please!
I use this system all the time!

ncdu -x to instruct it not to traverse foreign filesystems

TIL that my `.xsession-errors` file is ~16GB. Thanks, `ncdu`!

(I should probably look into this...)

It's a neat tool. Not quite clear why it's #1 on hn though?
One I don't see mentioned here is xdiskusage (for Linux) which gives a nice 20th century style X11 tree view of your disk usage.

xdiskusage -qa /

Have been using ncdu for more than a decade, and recently started using diskonaut for similar purposes. Was looking for a terminal-based treemap visualization for analyzing disk usage and stumbled upon diskonaut, which is exactly that.

https://github.com/imsnif/diskonaut

ncdu is one of the most useful tools I've come across to quickly get rid of unneeded files in remote servers. Top program.
I use ncdu a lot. It’s not strictly necessary but it’s really nice to have in the toolbox. Also IIRC there is a standalone binary available which comes in handy when you can’t install packages on a full filesystem.