LinuxCommandLibrary

dua

Analyze disk usage

TLDR

Analyze specific directory

$ dua [path/to/directory]
copy

Display apparent size instead of disk usage
$ dua --apparent-size
copy

Count hard-linked files each time they are seen
$ dua --count-hard-links
copy

Aggregate the consumed space of one or more directories or files
$ dua aggregate
copy

Launch the terminal user interface
$ dua interactive
copy

Format printing byte counts
$ dua --format [metric|binary|bytes|GB|GiB|MB|MiB]
copy

Use a specific number of threads (defaults to the process number of threads)
$ dua --threads [count]
copy

SYNOPSIS

dua [OPTIONS] [PATH ...]
dua interact [OPTIONS] [PATH ...]
dua estimate [OPTIONS] [PATH ...]
dua diff [OPTIONS] <PATH_A> <PATH_B>

PARAMETERS

-a, --apparent-size
    Display apparent size (actual bytes) instead of disk usage (allocated blocks).
This shows the logical size of files, ignoring sparse file optimizations or block allocation details.

-H, --human-readable
    Print sizes in human readable format (e.g., 1K, 234M, 2G).

-L, --dereference
    Dereference all symbolic links, counting the size of the target file/directory rather than the link itself.

-x, --no-cross-device
    Do not cross filesystem boundaries when traversing directories. This means it will only scan files on the same device as the starting path.

-s, --summarize
    Display only a total for each argument, rather than listing every entry (similar to du -s).

-d <N>, --depth <N>
    Limit the depth of the directory tree to N levels in non-interactive modes.

--disable-delete
    (interact mode) Disable the ability to delete files or directories directly from the interactive interface, providing a safer browsing experience.

--no-progress
    (interact mode) Do not show scanning progress, which can sometimes be useful for scripting or when output clarity is preferred over real-time updates.

DESCRIPTION

dua is a powerful command-line utility for analyzing disk usage, serving as a modern alternative to traditional tools like du and ncdu. Written in Rust, it excels in performance, offering exceptional speed for scanning large file systems.

It provides two primary modes of operation: a non-interactive mode similar to du (accessible via the estimate subcommand or as default for simple output), and an interactive terminal user interface (TUI) mode (via the interact subcommand or default if no specific subcommand is given and output is to a terminal).

The interactive TUI is dua's flagship feature, providing a responsive, graphical tree-like view of disk space consumption. Users can navigate directories, inspect file sizes, and even delete files or directories directly within the interface, making it incredibly efficient for identifying and managing disk space hogs. Its intuitive design and performance make it a popular choice for system administrators and users seeking to free up disk space.

CAVEATS

When using the interactive TUI, be extremely cautious with the delete functionality, as it can permanently remove files and directories. Always double-check your selection before confirming any deletion. dua can be I/O intensive on systems with slow disks or when scanning extremely large file systems with millions of small files.

INTERACTIVE MODE

dua's interactive mode (accessed via dua interact or often just dua) is its most prominent feature. It provides a real-time, hierarchical, and color-coded view of disk space. Users can navigate using arrow keys, collapse/expand directories, and perform actions like deleting selected items. This visual representation makes it significantly easier to pinpoint disk space bottlenecks than traditional command-line output.

SUBCOMMANDS

dua structures its functionalities around subcommands:
estimate: The default non-interactive behavior, similar to du, for calculating and printing disk usage.
interact: Launches the interactive TUI for exploring and managing disk space.
diff: A unique subcommand that allows comparing the disk usage of two specified paths, highlighting differences in size.

PERFORMANCE

Due to its implementation in Rust and efficient file system traversal algorithms, dua is often cited for its remarkable speed. It leverages parallel processing to scan directories quickly, making it a superior choice for analyzing very large or complex file systems where other tools might be slow or cumbersome.

HISTORY

dua emerged as a modern utility built with Rust, a language known for its performance and memory safety. It was developed to address some limitations and offer a more intuitive experience compared to older disk usage tools. While specific historical dates are not always widely publicized for open-source projects, its initial development and first stable releases generally fall into the late 2010s to early 2020s, quickly gaining traction within the Linux community for its speed and interactive capabilities.

SEE ALSO

du(1), ncdu(1), df(1), ls(1)

Copied to clipboard