Ncdu - Disk Usage Analyzer
Ncdu (NCurses Disk Usage) is a powerful command-line utility for analyzing disk space usage on Unix-like operating systems. It provides an interactive interface to navigate through directories and files, showing their sizes and helping you identify what's consuming your disk space.
Understanding Ncdu Commands
Ncdu offers several options for saving and loading scan results, which can be particularly useful for analyzing large file systems or for later review. Here are some common command-line usages:
Saving Scan Results
To save the current disk usage scan to a file, you can use the
-o option followed by the desired filename. This
creates a snapshot of your disk usage at that moment.
# To save results to <file>:
ncdu -o <file>
Reading Scan Results
You can load a previously saved scan result using the
-f option, followed by the path to the saved file. This
allows you to review disk usage without rescanning.
# To read from <file>:
ncdu -f <file>
Saving to Compressed Files
For large scan results, it's often beneficial to compress the
output. You can pipe the output of ncdu -o- to a
compression utility like gzip.
# To save results to a compressed file:
ncdu -o- | gzip > <file.gz>
Reading from Compressed Files
Similarly, you can decompress a saved file using
zcat and pipe it to ncdu -f- to read the
results.
# To read from a compressed file:
zcat <file.gz> | ncdu -f-
Key Features of Ncdu
Ncdu's interactive interface allows for easy navigation and sorting of directories by size. It's an essential tool for system administrators and developers who need to manage disk space efficiently. Its ability to export and import scan data makes it versatile for various workflows.