Hubbry Logo
NcduNcduMain
Open search
Ncdu
Community hub
Ncdu
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Ncdu
Ncdu
from Wikipedia
NCurses Disk Usage
DeveloperYoran Heling
Initial releaseFebruary 21, 2007; 18 years ago (2007-02-21)[1]
Stable release
2.9.1[2] Edit this on Wikidata / 21 August 2025; 2 months ago (21 August 2025)
Repository
Written inC (version 1.x), Zig (version 2.x)
Operating systemLinux, BSD, UNIX
PlatformPOSIX
TypeDisk utility
LicenseMIT License
Websitedev.yorhel.nl/ncdu

ncdu (NCurses Disk Usage) is a disk utility for Unix systems. Its name refers to its similar purpose to the du utility, but ncdu uses a text-based user interface under the [n]curses programming library.[3] Users can navigate the list using the arrow keys and delete files that are taking up too much space by pressing the 'd' key. Version 1.09 and later can export the file listing in JSON format.

ncdu was developed by Yoran Heling to learn C and to serve as a disk usage analyzer on remote systems over ssh. Version 2.0 of the program brought a full rewrite in the Zig programming language.[4]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
ncdu (NCurses Disk Usage) is a free and open-source command-line tool that provides an interactive, text-mode interface for analyzing disk usage on Unix-like operating systems, helping users identify and manage large files and directories that consume significant storage space. Developed by Yorhel as a lightweight alternative to graphical disk analyzers, ncdu was first released in 2007 and has evolved through multiple versions, with the stable 1.x series written in C and the 2.x series rewritten in the Zig programming language for improved performance and maintainability. The tool is licensed under the MIT License, making it freely available for modification and distribution, and it is actively maintained via a public Git repository. Key features of ncdu include its ncurses-based interface for navigating a tree-like directory structure, support for parallel scanning to speed up analysis on multi-core systems, and the ability to export usage data in or other formats for further processing. It runs efficiently on resource-constrained environments like remote servers, where graphical tools are impractical, and supports a wide range of platforms including distributions, macOS, , Solaris, and even Windows via compatibility layers. As of October 2025, the latest release is version 2.9.2, which includes enhancements like color-coded output and binary export options for handling very large filesystems without excessive usage. ncdu is widely packaged in major repositories and appreciated for its simplicity and speed compared to traditional command-line utilities like du, enabling quick and space optimization tasks.

Overview

Description

ncdu, short for NCurses Disk Usage, is a disk usage analyzer featuring a constructed using the library. It serves as a curses-based equivalent to the standard Unix du command, enabling users to interactively explore and visualize directory sizes in a hierarchical manner. The tool is primarily designed to rapidly pinpoint large files and directories that consume significant disk space, making it especially valuable for managing storage on remote servers accessed via SSH, where graphical interfaces are unavailable. While optimized for such environments, ncdu remains effective on local desktops lacking dedicated disk analysis software. Technically, ncdu is POSIX-compatible and targets POSIX-like operating systems, including Linux, BSD variants, macOS, and Windows through available packages or ports. Version 1.x is implemented in C, whereas version 2.x utilizes the Zig programming language, with the project released under the MIT License. In its basic operation, ncdu scans one or more specified directories—or the current directory by default—and presents the results through a navigable, full-screen ncurses interface that displays disk usage as an interactive tree view. Users can traverse the hierarchy, delete files directly, and perform other actions to reclaim space efficiently.

Purpose and advantages

Ncdu was developed to overcome the shortcomings of the traditional du command, which provides only static output and lacks interactivity, making it challenging to explore and visualize large filesystem datasets, particularly on remote systems accessed via SSH without graphical capabilities. This tool addresses these limitations by offering a curses-based interface that enables real-time navigation and analysis directly in the terminal. Key advantages of ncdu include its superior scanning speed compared to du, achieved through multi-threaded processing that parallelizes directory traversal for quicker results on multi-core systems. It provides an intuitive, keyboard-driven navigation system for browsing directory hierarchies, along with the ability to delete files and directories directly from the interface, streamlining cleanup operations. Additionally, ncdu supports color-coded displays and graphical size representations, such as progress bars, to enhance readability and highlight space-intensive items without overwhelming the user. Ncdu is particularly valuable for system administrators tasked with troubleshooting disk space issues, identifying and removing unnecessary files on servers, or conducting filesystem usage analysis in resource-constrained, terminal-only environments like remote hosts. Unlike graphical alternatives, which require a , or the non-interactive du, ncdu delivers a portable, lightweight solution that balances high performance, ease of use, and direct action capabilities in command-line settings.

History

Initial development

ncdu was developed by Yoran Heling, who is known online as Yorhel, beginning in 2007. The project originated as a lightweight tool to analyze disk usage, particularly suited for remote servers accessed via SSH in environments without graphical interfaces. It emphasized simplicity and efficiency, focusing initially on core functionalities like directory scanning and a navigable for exploring usage. The first public version, 0.1, was released on , 2007, providing a basic curses-based interface as an interactive alternative to the traditional 'du' command. This early iteration laid the groundwork for quick disk space assessment over low-bandwidth connections. From its start, ncdu was hosted in a public repository at g.blicky.net/ncdu.git and distributed under the , allowing broad adoption and modification. Key milestones in the initial 1.x series marked rapid evolution. Version 1.0, released on April 6, 2007, introduced the core interface with visual graphs for size representation and a toggle for basic sorting by size or name. Subsequent releases built on this foundation: 1.1 (April 30, 2007) added capabilities and refined sorting via the 't' key; 1.2 (July 24, 2007) implemented exclusion patterns similar to 'du' for skipping directories; and by 1.3 (August 5, 2007), refresh functionality ('r' key) and toggling between apparent size and disk usage ('a' key) were included. Through 2008-2010, further 1.x versions enhanced stability, such as detection in 1.6 (2009) and performance fixes, solidifying ncdu's role as a portable disk analyzer.

Rewrite and major versions

In 2021, ncdu underwent a significant architectural shift with the release of version 2.0 on December 21, which completely rewrote the tool from C to the Zig programming language. This rewrite was driven by the need to reduce memory overhead, address slow directory counting in large filesystems, improve overall performance, enhance memory safety, and facilitate better long-term maintainability and scalability for future features like parallel processing. Despite the language change, version 2.0 preserved backward compatibility with the 1.x series, ensuring seamless transition for existing users. The 1.x series, originally implemented , continues to receive (LTS) for stability in production environments, with its latest release, version 1.22, issued on March 5, 2025. In parallel, the 2.x series remains the focus of active development, culminating in version 2.9.2 on October 24, 2025, which incorporates ongoing refinements to Zig-based features. Notable advancements in the 2.x lineage include the introduction of parallel scanning in version 2.5 (July 24, 2024), enabling multi-threaded directory traversal via the -t or --threads option to accelerate analysis on multi-core systems. Version 2.6 (September 27, 2024) further expanded export capabilities with a new binary format (-O flag), supporting built-in compression through --compress-level for efficient handling of large datasets and low-memory scenarios. Several user-facing refinements have iterated across versions, particularly regarding color support in the interface. Introduced experimentally in 1.13 (January 29, 2018), colors became the default in 1.17 (April 28, 2022) and 2.0 (December 21, 2021) with a 'dark-bg' scheme for better visibility. However, due to reported legibility issues in varied terminal environments, defaults were reverted to off in 1.20 and 2.4 (both April 21, 2024), while retaining customizable schemes like --color=dark. The 2.x series also enhanced export/import performance (building on the format established in 1.9), added static binary builds for simplified cross-platform distribution without dependencies, and improved overall compatibility across systems. Maintenance efforts treat the 1.x branch as a stable LTS option for conservative deployments, while 2.x drives innovation with additions like export compression and broader platform support, including older kernels in later releases. As an open-source project, ncdu's evolution relies on community input through its issue tracker at code.blicky.net, with widespread packaging in major distributions such as (version 1.22 integrated March 2025) and (version 2.9.1 updated August 2025).

Features

User interface

ncdu features a ncurses-based user interface that provides an interactive, text-mode display for exploring disk usage within a terminal. The core layout consists of a hierarchical tree view listing directories and files, initially sorted by disk usage in descending order to highlight space-intensive items first. Each entry displays the item name, its size in human-readable format (such as bytes, KB, MB, or GB), and a proportional graphical bar representing the relative size as a percentage of the parent directory's total. At the bottom of the screen, a summary line reports the total size of the scanned directory and the total number of items analyzed. This design enables quick identification of large consumers of storage space. Navigation through the interface is exclusively keyboard-driven, ensuring compatibility with remote terminal sessions lacking graphical capabilities. Users move up and down the list using the , or vi-style 'j' and 'k' bindings for efficiency. Pressing Enter, the right arrow, or 'l' opens the selected directory to drill down into its contents, while the left arrow, , or 'h' returns to the parent directory. The 'q' key exits the application, optionally prompting for confirmation to prevent accidental closure. Deletion of the currently selected file or directory is initiated with 'd', followed by a confirmation dialog unless disabled via configuration; in read-only mode (activated with -r), this function is unavailable. Sorting can be toggled with keys such as 's' for (disk usage or apparent based on current display mode, toggled with 'a'), 'n' for name (alphabetical), 'C' for item count, or 'M' for modification time (requires extended mode). Additional toggles include 't' to alternate between showing directories before or after files, 'e' to show or hide hidden and excluded files from the view, 'c' to display item counts, 'm' to show modification times (requires extended mode), 'g' to switch between percentage display and graphical bars (with styles like hash marks or block characters), and 'u' to include shared calculations. The view can be refreshed and recalculated with 'r', useful after external changes to the filesystem. A contextual help screen detailing all keys is accessible by pressing '?'. Visual elements enhance usability, including a displayed during the scanning or importing process when using the full-screen mode (-2 option, with real-time updates), terminal progress bar mode (-1), or no feedback (-0). Color support, introduced in version 1.13 and configurable since version 1.17, can be enabled via the --color option set to 'dark' for light terminal backgrounds or 'darkbg' for dark ones, improving contrast and over the default mode; it was temporarily disabled by default in later versions (1.20 and 2.4) due to terminal compatibility issues but remains available. Status flags appear as single characters next to entries, such as '!' for a read in the directory, '.' for an in a subdirectory (potentially leading to inaccurate sizes), '<' for items excluded from statistics, '>' for items on other filesystems, '^' for pseudo-filesystems, '@' for items that are not files or directories, 'H' for hard links, and 'e' for empty directories. These flags help users identify anomalies without disrupting the primary layout. Customization extends to display preferences, allowing users to tailor the interface via runtime keys or a for persistent settings like color mode. For handling large datasets, ncdu optimizes redrawing through efficiency, supports multi-threaded scanning to minimize initial load times, and permits browsing of massive trees in low-memory mode by importing pre-scanned binary files (-O option), avoiding the need to reload the entire structure. The interface requires no input and performs reliably in standard terminal emulators with widths of at least 80 columns, adapting to available screen space while maintaining readability. This keyboard-centric, lightweight design makes ncdu particularly effective for server environments and quick analyses.

Scanning and analysis tools

Ncdu employs a depth-first traversal for scanning directories, akin to the traditional du command, which recursively processes subdirectories before aggregating sizes upward in the tree. This approach enables efficient construction of the directory hierarchy during the initial scan phase. To provide user feedback during scanning, ncdu utilizes an ncurses-based progress indicator in full-screen mode (activated with -2), a terminal progress bar (-1), or silent operation (-0). The tool supports excluding specific patterns via the --exclude option or by reading from a file with --exclude-from, allowing users to omit irrelevant paths like temporary files or caches from the analysis. Additionally, the -x flag confines scanning to the starting filesystem, preventing cross-device traversals that could include mounted volumes unintentionally, while --cross-file-system permits such crossings when needed. Once scanned, ncdu offers real-time analysis capabilities within its interface, including sorting entries by (default, using current display mode of disk usage or apparent size), name, item , or modification time (requires extended mode). Filtering mechanisms allow toggling visibility of hidden or excluded files with the 'e' key or command-line options like --show-hidden or --hide-hidden. A key analytical feature distinguishes between apparent size—representing the logical file length, which is particularly relevant for sparse files where gaps are not allocated on disk—and allocated disk usage, measured in blocks; this is toggled via --apparent-size or the default --disk-usage, and can be switched in the interface with the 'a' key. Such computations aid in identifying space inefficiencies, like sparse images that report high apparent sizes but low actual storage consumption. Performance is optimized for large filesystems through low design, storing the directory tree compactly in RAM or via optional binary exports. In version 2.5 and later, parallel directory scanning is available using the -t option (e.g., -t8 for eight threads), accelerating the process on multi-core systems or networked storage, though it remains disabled by default to ensure compatibility. The binary export format introduced in 2.6 further enhances efficiency by supporting compressed, low-memory scanning for datasets exceeding available RAM, allowing deferred loading and browsing. Error handling during scanning prioritizes robustness: unreadable files or directories are skipped automatically, with issues flagged in the interface using symbols like ! for inaccessible directories or . for problematic subdirectories, ensuring the scan completes without halting. These errors are logged visibly for review without disrupting the overall process. To maintain data accuracy, ncdu detects hard links and marks them with an H indicator, counting their size only once in the total to prevent double-counting across the filesystem; however, shared size attributions may vary if links are modified post-scan. Remote scanning is facilitated by piping output from an SSH session (e.g., ssh user@host ncdu -co- /path | ncdu -f-), enabling analysis of distant systems while viewing locally, which avoids running the full interface remotely.

Export and customization options

Ncdu provides several options for , enabling integration with scripts and other tools. The primary export format is , invoked with the -o file flag, which outputs the directory tree structure to a specified file or standard output if - is used. This format includes detailed metadata such as program version, timestamp, and per-entry information like apparent size (asize), disk usage (dsize), inode numbers, and exclusion reasons, allowing for programmatic of file paths, sizes, and attributes. Introduced in version 2.6, the binary export format uses the -O file flag and offers advantages over JSON, including built-in Zstandard compression, support for parallel scanning with reduced buffering, and efficient handling of large directory trees through cumulative size calculations. This format consists of compressed data blocks and an index, making it suitable for high-volume exports while maintaining compatibility for import via -f. Compression can be further tuned with --compress-level (1-19, default 4), and block sizes adjusted via --export-block-size (4-16,000 KiB). Customization flags allow tailoring ncdu's behavior to specific environments. Color output can be disabled with --color off, or set to dark themes (--color dark or --color dark-bg) for better visibility on various terminals. By default, ncdu crosses filesystem boundaries (--cross-file-system), but this can be disabled with -x to limit scans to the starting device. Hidden files are included by default, but can be excluded with --hide-hidden. Sessions can be saved during scans and restored later using -f file for the or binary format, supporting incremental . Extended mode (-e) enables additional details like modification times and ownership, at the cost of higher memory usage. For refined control, ncdu supports exclusion patterns via --exclude pattern (e.g., to skip caches or temporary files like --exclude '*/cache/*') or -X file for loading patterns from a file. Parallel scanning, available since version 2.5, uses -t num to specify thread count (default 1), enhancing performance on multi-core systems as briefly noted in scanning tools. These options extend ncdu's utility in , where exports can be piped from remote commands (e.g., ssh user@host ncdu -co- /path | ncdu -f-) or processed in scripts like Python for generating reports or dashboards.

Usage

Installation

Ncdu is available through package managers on most systems, facilitating easy installation without manual compilation. On and , it can be installed using apt install ncdu from the official repositories. For , the command is dnf install ncdu, while users can run pacman -S ncdu. provides it via pkg install ncdu, and macOS users can install it with Homebrew using brew install ncdu. These packages typically include version 1.x for stability, though availability may vary by distribution. For users preferring to build from source, ncdu offers options for both its 1.x (written in ) and 2.x (written in Zig) versions. To compile version 1.x, clone the repository with git clone git://g.blicky.net/ncdu.git, switch to the 'master' branch, and run make followed by make install, requiring a C compiler and ncurses development libraries. Version 2.x requires the Zig compiler (version 0.14 or 0.15); after cloning and switching to the 'zig' branch, use zig build -Doptimize=ReleaseSafe and zig build install for installation. Source tarballs are downloadable from the official site for releases without . Static binaries are provided for quick deployment on architectures such as x86_64, , and , eliminating dependency issues; these can be downloaded from dev.yorhel.nl/download and extracted for immediate use. Binaries for other platforms, including Tru64 UNIX, are also available. Ncdu natively supports systems including distributions, BSD variants (, , , DragonFlyBSD), AIX, Solaris, and macOS. There is no official native Windows port, but it runs on Windows via environments like or (WSL). For version selection, the 1.x series (latest LTS: 1.22) is recommended for production environments due to its maturity and wide package availability, while 2.x (latest: 2.9.2) offers newer features but requires the Zig toolchain for building. Users should check their distribution's repositories for the bundled version before opting for source or binary methods.

Basic operation

To invoke ncdu for basic disk usage analysis, run the command ncdu in the terminal to scan the current directory, or specify a path such as ncdu /path/to/scan to target a particular location. Upon execution, ncdu initiates an initial scan of the selected directory tree, displaying a progress indicator as it calculates disk usage for files and subdirectories. This process typically completes quickly for most systems, after which the tool loads an interactive, full-screen curses-based interface showing the total size of the scanned directory at the bottom of the screen, along with a sorted list of its largest subdirectories and files by default. In the core workflow, users navigate the using keyboard controls: the up and down (or j and k) to cycle through items in the list, the right , Enter, or l to enter a selected subdirectory for deeper exploration, and the left or h to return to the parent directory. The interface presents both absolute sizes (in human-readable formats like KB, MB, or GB) and relative percentages of the total usage for each item, with the percentage view toggleable via the g key if needed. To exit the tool at any point, press q, which quits the program without saving any data unless previously configured otherwise. For simple cleanup during analysis, select an item with the navigation keys and press d to mark it for deletion; ncdu prompts for confirmation (typically requiring a y response) before proceeding, ensuring accidental removals are avoided. After deletion, the tool automatically refreshes the in-memory view of the directory to reflect the updated sizes and structure, allowing continued exploration without restarting the scan. Upon quitting, ncdu displays summary statistics of the overall scan, such as the total disk usage, but does not persist any files or reports by default.

Advanced commands

Ncdu provides several command-line options for handling complex scanning scenarios, such as excluding specific patterns or limiting the scope of analysis. The --exclude option allows users to skip files or directories matching a given pattern, which is useful for ignoring temporary files or directories during scans; for example, ncdu --exclude '*.tmp' /path will omit all files ending in .tmp. Similarly, -X or --exclude-from reads exclusion patterns from a file, enabling reusable configurations like those stored in ~/.ncduexcludes. To restrict scanning to a single filesystem and avoid crossing mount points, the -x or --one-file-system is employed, as in ncdu -x / for analyzing only the filesystem. For performance optimization in ncdu version 2.x and later, the -t or --threads option enables multi-threaded scanning, specifying the number of threads to utilize; for instance, ncdu -t 4 /path leverages four threads to accelerate the process on multi-core systems. Saved scans can be loaded into the interactive interface using -f followed by the savefile path, such as ncdu -f previous-scan.ncdu, allowing reuse of prior analyses without rescanning the filesystem. Input can also be piped from standard input in format via -f -, facilitating integration with other tools that generate compatible data. Remote disk usage analysis is supported through SSH by executing ncdu on a distant host and piping the output back locally, for example, ssh user@host ncdu -co- /path | ncdu -f-, where -c enables compression and -o- exports to stdout in for efficient transfer. Alternatively, running ssh user@host ncdu /path directly invokes the interactive interface on the remote if ncdu is installed there. For automation, ncdu can export scans to format with -o report.json /home, producing structured output suitable for parsing in scripts; this can be scheduled via for periodic monitoring, such as 0 2 * * * ncdu -0x -o /var/log/disk-report.json / to run nightly while suppressing interactive output with -0. Troubleshooting options address environmental issues, including --color off to disable colors in terminals that do not support them properly, ensuring compatibility in scripts or remote sessions. While there is no built-in depth limit, selective exclusion patterns can approximate depth control by targeting deeper subdirectories. For integration with alerting systems, scripts can parse the export to check for directories exceeding size thresholds, triggering notifications when usage surpasses predefined limits, such as integrating with tools like or jq for automated reports.
Add your contribution
Related Hubs
User Avatar
No comments yet.