NCDU: NCurses Disk Usage

ncdu is a command line tool to scan and calculate directory and file sizes.

Comparison with ‘du’

While the initial scan is about the same as du, ncdu keeps the results in memory. This can become handy when investigating the storage hog. You can compare the already cached results immediately with a (r) escan.

Also navigation is a breese. ncdu creates a interactive session where the arrow keys are used to open and close directories.

Options

ncdu is not bloated with options, but each of these are useful and easy to remember. All these are used inside the interactive session.

Key Description
up, k Move cursor up
down, j Move cursor down
right/enter Open selected directory
left, <, h Open parent directory
n Sort by name
s Sort by size
C Sort by items
d Delete selected file or directory
t Toggle dirs before files when sorting
g Show percentage and/or graph
a Toggle between apparent size and disk usage
c Toggle display of child item counts
e Show/hide hidden or excluded files
i Show information about selected item
r Recalculate the current directory
b Spawn shell in current directory
q Quit ncdu

Advanced ncdu

JSON for development

ncdu -x / -o- | jq
  • -x chose directory ‘/’
  • -o- output to stdout

Will create a JSON object of the current directory and all his subdirectories. This can come handy for developing or generating reports.

Store result

ncdu -0xo- / | gzip > scan.gz
  • -0 surpress unwanted output
  • -x chose directory ‘/’
  • -o- output to stdout

Use stored result

zcat scan.gz | ncdu -f-
  • -f read from stdin

Author

Official Website

comments powered by Disqus