Traditional command-line utilities for analysing filesystems typically force developers and system administrators to choose between structural hierarchy and storage utilisation. The classic tree command provides clean visual representations of directory structures but lacks nuanced disk-usage analytics, whilst du provides raw byte tallies without hierarchical context. To bridge this divide, modern Linux environments increasingly rely on erdtree (invoked as et). Written in Rust, erdtree is a multi-threaded, colourised filesystem tool that simultaneously outputs an aesthetic directory tree alongside detailed file sizes, disk allocations, and file metadata.
Key Advantages of erdtree Over Standard CLI Utilities
Unlike single-threaded predecessors, erdtree leverages multi-core processor architectures to traverse complex directory branches asynchronously. Core architectural advantages include:
- Unified Reporting: Combines the visual layout of
treewith the capacity breakdown ofduin a single pass. - Intelligent Sizing: Accurately reports physical block allocations on disk as well as logical byte lengths, correctly accounting for sparse files and hard links.
- VCS Awareness: Respects
.gitignorerules by default, avoiding sluggish traversal of bloatednode_modules,target/, or.gitmetadata directories. - Customisable Visualisation: Supports multiple layout modes, custom depth limits, file attribute sorting, and regex-based inclusion/exclusion filtering.
Installing erdtree on Linux
Because erdtree is developed in modern Rust, installation is straightforward across standard distributions using Cargo, precompiled release binaries, or package managers.
Method 1: Installing via Cargo (Universal)
If you have Rust and Cargo installed, compile and install erdtree directly from crates.io:
cargo install erdtree
Ensure your user binary path is included in your active shell environment by confirming ~/.cargo/bin is in your $PATH variable:
echo $PATH | grep -q "$HOME/.cargo/bin" || echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Method 2: Installing Precompiled Binaries from GitHub
For headless production servers lacking developer build chains, download the precompiled tarball from the official GitHub releases repository:
VERSION=$(curl -s https://api.github.com/repos/solidiquis/erdtree/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\\1/')
wget "https://github.com/solidiquis/erdtree/releases/download/${VERSION}/erd-x86_64-unknown-linux-musl.tar.gz"
tar -xzf erd-x86_64-unknown-linux-musl.tar.gz
sudo mv erd /usr/local/bin/et
sudo chmod +x /usr/local/bin/et
Verify that your installation is functional by checking the version string:
et --version
Basic Usage and Directory Visualisation
Running et without arguments in any directory displays an immediate hierarchical tree decorated with size metrics, permissions, and colour-coded node icons:
et
By default, erdtree outputs file sizes formatted into human-readable units (KiB, MiB, GiB) and prints the cumulative size of each folder alongside the directory name.
Limiting Directory Traversal Depth
When inspecting deep software projects or nested server logs, unbounded traversal can produce overwhelming output. Limit search depth using -L (level):
et -L 2
This restricts the tree to two subdirectory layers, enabling immediate bird’s-eye views of storage consumption.
Sorting Output by Disk Usage
To identify the largest disk-space consumers within a folder tree, tell erdtree to sort nodes by size rather than alphabetical file names using -s (sort):
et -s size -r
The -r switch reverses sorting, placing the heaviest subdirectories and files at the bottom of the terminal output for instant visibility without scrolling up.
Advanced Features and Filtering Options
erdtree provides fine-grained controls tailored for advanced development and administrative triage:
Displaying Hidden Files and Disabling Gitignore
By default, erdtree omits dotfiles and patterns specified in .gitignore. To inspect hidden dotfiles (such as .env or .config/), pass the -H flag:
et -H
To disable Git ignore filtering completely and inspect raw compiler output or dependencies:
et --no-git
Outputting in Flat or Table Views
If you prefer a structured column table over a branch-line tree diagram, switch the visual display layout using the --layout option:
et --layout regular
To compute disk usage strictly without displaying child files (mimicking summary tools like du -sh *):
et --layout flat -L 1
Filtering by File Extensions and Regex
You can isolate specific file formats, such as finding all log files or configuration manifests within a sprawling architecture:
et --glob "*.log"
et -I ".*.ya?ml$"
Creating Handy Aliases for Daily Workflows
To make disk inspections instantaneous, integrate convenient aliases into your shell configuration (e.g. ~/.bashrc or ~/.zshrc):
echo "alias et2='et -L 2 -s size -r'" >> ~/.bashrc
source ~/.bashrc
Running et2 now produces a clean two-level storage breakdown sorted by file size directly inside your terminal.