LinuxCommandLibrary

dutree

List directory contents with disk usage

TLDR

Show a graphical tree of the current directory

$ dutree
copy

Show a specific directory
$ dutree [path/to/directory]
copy

Aggregate items smaller than a number of KB (or M for MB, or G for GB)
$ dutree --aggr [number]K
copy

Show subdirectories up to the specified depth (default is 1)
$ dutree --depth [depth]
copy

Skip directories for a fast local overview
$ dutree --files-only
copy

Exclude hidden files
$ dutree --no-hidden
copy

SYNOPSIS

dutree [options] [directory...]

Example: dutree -h -L 2 /var/log

PARAMETERS

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

-L <level>, --level <level>
    Descend only <level> directories deep. A value of 1 shows only direct children.

-d, --directories-only
    List directories only, omitting individual files from the output tree.

-a, --all
    Include hidden files and directories (those starting with a dot) in the output.

-x, --one-file-system
    Skip directories that are on different file systems than the starting directory.

-I <pattern>, --exclude <pattern>
    Exclude files or directories whose names match the specified <pattern>.

--total
    Display a grand total disk usage at the end of the output.

DESCRIPTION

`dutree` is a powerful, though not standard, command-line utility designed to provide a comprehensive, tree-like visualization of disk space usage. It effectively combines the functionality of `du` (disk usage) and `tree` (list directory contents in a tree-like format) into a single, easy-to-read output. This utility is typically implemented as a shell script by the community to address the common need for a quick, visual overview of how disk space is distributed across directories and files. Unlike `du` which lists sizes line by line, or `tree` which only shows structure, `dutree` presents directory sizes directly within a hierarchical structure, making it exceptionally useful for identifying disk space hogs and managing storage efficiently. Its non-standard nature means implementations can vary, but the core objective remains consistent: to provide an intuitive, navigable insight into your file system's storage consumption.

CAVEATS

Unlike standard Linux commands, `dutree` is typically a community-developed script or utility, meaning its exact behavior, available options, and even its existence can vary significantly between systems.
Users should be aware that it often relies on the underlying `du` and `tree` commands being installed and accessible in the system's PATH.
When dealing with extremely large or deeply nested file systems, `dutree` can be resource-intensive and may take considerable time to execute.
Furthermore, as it's often sourced from various community repositories, users should exercise caution and verify the script's content before execution to prevent potential security risks.

INSTALLATION AND AVAILABILITY

As `dutree` is not part of standard Linux distributions, users typically install it by downloading a script from a community repository (e.g., GitHub) or by creating their own script. The downloaded script usually needs to be made executable (`chmod +x dutree`) and placed in a directory included in the system's PATH (e.g., `/usr/local/bin` or `~/bin`). It is highly recommended to review the script's content before execution to ensure its safety and intended functionality.

TYPICAL USAGE

`dutree` is primarily used for disk space analysis and cleanup. Users frequently employ it to:
1. Quickly identify which directories are consuming the most disk space.
2. Visualize the size distribution within a specific project directory.
3. Audit file system usage after large data operations.
4. Find large, unnecessary files or directories that can be archived or deleted.
The various options allow for granular control, such as limiting the depth of the tree (`-L`), showing human-readable sizes (`-h`), or excluding specific file types (`-I`).

HISTORY

The history of `dutree` is not one of a single, formally developed project, but rather an organic emergence from the practical needs of Linux users. Faced with the separate functionalities of `du` (for disk usage reporting) and `tree` (for hierarchical directory listing), users often sought a unified tool to visualize disk space directly within a directory structure. This led to numerous independent shell script implementations shared across personal dotfiles, online forums, and platforms like GitHub. These scripts typically combined piping the output of `du` into a processing logic that reformatted it into a `tree`-like display. Consequently, `dutree` represents a common solution pattern rather than a canonical command, continuously evolving through community contributions based on diverse user requirements and preferences.

SEE ALSO

du(1), tree(1), ncdu(1), find(1)

Copied to clipboard