thelinuxvault guide

Best Tools for Visualizing Linux Disk Usage

Managing disk space is a critical task for Linux users and system administrators. As storage fills up, it can lead to performance degradation, application failures, or even system crashes. While command-line tools like `df` and `du` provide raw data on disk usage, they often lack context—making it hard to identify *where* space is being consumed (e.g., large log files, redundant backups, or bloated application directories). Visual disk usage tools solve this by transforming raw numbers into intuitive, interactive visualizations (e.g., treemaps, sunburst charts, or bar graphs). These tools make it easy to spot trends, locate large files, and clean up unnecessary data. In this blog, we’ll explore the best tools for visualizing Linux disk usage, covering both terminal-based (CLI) and graphical (GUI) options to suit different workflows.

Table of Contents

  1. ncdu (NCurses Disk Usage Analyzer)
  2. Filelight
  3. Baobab (Disk Usage Analyzer)
  4. QDirStat
  5. gdu (Go Disk Usage Analyzer)
  6. duc (Disk Usage Cache)
  7. Bonus: Enhancing df and du with Visualization Tips
  8. Tool Comparison Table
  9. Conclusion
  10. References

1. ncdu (NCurses Disk Usage Analyzer)

What is ncdu?

ncdu (NCurses Disk Usage) is a lightweight, terminal-based tool that transforms the output of du (disk usage) into an interactive, navigable interface. Built on the ncurses library, it’s designed for systems without a GUI (e.g., servers) but works equally well on desktop environments.

Key Features

  • Interactive Navigation: Use arrow keys to drill into directories and explore nested files.
  • Detailed Metrics: Displays size (bytes, KB, MB, GB), percentage of total disk space, and file/directory names.
  • File Management: Delete files/directories directly from the interface (with confirmation prompts).
  • Speed: Scans directories quickly, even on large filesystems.

Installation

ncdu is pre-packaged for most Linux distributions:

  • Ubuntu/Debian: sudo apt install ncdu
  • Fedora/RHEL: sudo dnf install ncdu
  • Arch Linux: sudo pacman -S ncdu

Usage Example

To analyze disk usage for a specific directory (e.g., /home), run:

ncdu /home  

Navigation Tips:

  • Use ↑/↓ arrow keys to move between entries.
  • Press → to drill into a directory, ← to go back.
  • Press d to delete a file/directory (confirm with y).
  • Press q to quit.

ncdu Screenshot
ncdu interface showing disk usage for a /home directory.

Pros and Cons

ProsCons
Lightweight (no GUI dependencies)Terminal-only; less visually intuitive for some users.
Fast and efficient for large directoriesLimited to text-based interaction.
Works over SSH (great for remote servers)No built-in search (use du with grep for pre-scan filtering).

2. Filelight

What is Filelight?

Filelight is a graphical disk usage analyzer designed for the KDE desktop environment. It uses a sunburst chart (a circular, nested ring visualization) to represent disk usage, where larger segments correspond to larger files/directories.

Key Features

  • Sunburst Visualization: Rings represent nested directories; hover over segments to see details (size, path).
  • Interactive Controls: Click segments to zoom in, right-click to delete/move files, or search for specific items.
  • KDE Integration: Seamlessly works with KDE Plasma, including context menus and file associations.

Installation

  • Ubuntu/Debian: sudo apt install filelight
  • Fedora/RHEL: sudo dnf install filelight
  • Arch Linux: sudo pacman -S filelight
  • KDE Users: Often pre-installed with KDE Plasma.

Usage Example

Launch Filelight from your application menu, then:

  1. Click “Scan” and select a directory (e.g., / for the entire system).
  2. Explore the sunburst chart: Larger, brighter segments indicate bigger files/directories.
  3. Right-click a segment to delete, copy, or open the directory in Dolphin (KDE’s file manager).

Filelight Screenshot
Filelight’s sunburst chart visualizing disk usage.

Pros and Cons

ProsCons
Visually striking sunburst chartHeavy KDE dependencies (may bloat non-KDE systems).
Intuitive for identifying large files at a glanceSlower than terminal tools on very large directories.
Built-in file operations (delete, move)Limited to GUI environments.

3. Baobab (Disk Usage Analyzer)

What is Baobab?

Baobab (also called “Disk Usage Analyzer”) is the default disk visualization tool for the GNOME desktop environment. It offers two primary views: a treemap (rectangular blocks, with size proportional to disk usage) and a ring chart (similar to Filelight’s sunburst).

Key Features

  • Treemap/Ring Views: Toggle between two visualizations to suit your preference.
  • Remote Scanning: Analyze disk usage on network shares (e.g., SSH, FTP) or external drives.
  • Snapshot Comparison: Save scans as snapshots and compare them to track usage over time.
  • Search: Filter results by file name or size.

Installation

  • Ubuntu/Debian: sudo apt install baobab (often pre-installed on GNOME).
  • Fedora/RHEL: sudo dnf install baobab
  • Arch Linux: sudo pacman -S baobab

Usage Example

  1. Launch Baobab from the GNOME menu (search for “Disk Usage Analyzer”).
  2. Click “Scan Folder” and select a directory (e.g., /var for system logs).
  3. Use the dropdown to switch between “Treemap” and “Ring” views.
  4. Double-click a block/segment to drill into subdirectories.

Baobab Screenshot
Baobab’s treemap view showing disk usage in /var.

Pros and Cons

ProsCons
Native GNOME integrationLess feature-rich than QDirStat (e.g., no bulk cleanup tools).
Dual visualization modesSlower than ncdu or gdu for large scans.
Remote and snapshot supportLimited to GUI environments.

4. QDirStat

What is QDirStat?

QDirStat is a cross-platform GUI tool inspired by WinDirStat (a popular Windows disk analyzer). It uses a treemap visualization with color-coded file types (e.g., red for video, blue for documents) to make it easy to identify file categories consuming space.

Key Features

  • Treemap with File Type Colors: Rectangles are colored by file extension (configurable).
  • Detailed File List: Side panel shows sorted list of files by size, with path and permissions.
  • Bulk Cleanup: Built-in tools to delete, compress, or move large files.
  • Exclusion Rules: Ignore temporary files, cache directories, or specific file types during scans.

Installation

  • Ubuntu/Debian: sudo apt install qdirstat
  • Fedora/RHEL: sudo dnf install qdirstat
  • Arch Linux: sudo pacman -S qdirstat
  • Source: GitHub (for other distros).

Usage Example

  1. Launch QDirStat and select a directory to scan (e.g., /).
  2. The treemap displays directories as nested rectangles; hover to see size and path.
  3. Use the “Cleanup” menu to delete files, or right-click entries for context actions.

QDirStat Screenshot
QDirStat’s treemap with color-coded file types.

Pros and Cons

ProsCons
Color-coded file types for quick identificationRequires Qt dependencies (may be large on minimal systems).
Powerful cleanup toolsSlower than terminal tools for initial scans.
Cross-platform (works on Linux, Windows, macOS)No ring/sunburst view (treemap only).

5. gdu (Go Disk Usage Analyzer)

What is gdu?

gdu (Go Disk Usage) is a modern, terminal-based alternative to ncdu, written in Go for speed and efficiency. It’s designed to handle large directories faster than ncdu by leveraging concurrency and optimized I/O operations.

Key Features

  • Speed: Up to 5x faster than ncdu on large filesystems (e.g., 1TB+ drives).
  • Interactive UI: Similar to ncdu (arrow keys for navigation, delete with d).
  • JSON Output: Export results to JSON for scripting or external analysis.
  • Lightweight: Minimal dependencies (only requires Go runtime).

Installation

gdu is available via package managers or binary downloads:

  • Ubuntu/Debian: sudo apt install gdu (via PPA for older versions).
  • Fedora/RHEL: sudo dnf install gdu
  • Arch Linux: sudo pacman -S gdu
  • Binary: Download from GitHub Releases.

Usage Example

To scan the root filesystem:

sudo gdu /  

Key Shortcuts:

  • Tab: Switch between “size” and “usage” (percentage) views.
  • Ctrl+L: Refresh the scan.
  • ?: Show help menu.

gdu Screenshot
gdu’s terminal interface, showing faster scan times than ncdu.

Pros and Cons

ProsCons
Faster than ncdu for large directoriesLess mature than ncdu (fewer plugins/community support).
JSON output for automationTerminal-only.
Lightweight and portableNo GUI option.

6. duc (Disk Usage Cache)

What is duc?

duc (Disk Usage Cache) is a unique tool that precomputes and caches disk usage data for fast subsequent scans. Instead of scanning the filesystem every time, it builds an index (stored in ~/.duc.db) that can be queried instantly.

Key Features

  • Cached Scans: Index directories once, then query the cache for instant results.
  • Multiple Interfaces: Supports terminal (ncurses), GUI (GTK), and web-based visualization.
  • Incremental Updates: Update the cache without re-scanning the entire directory.
  • Export Options: Generate HTML reports or PNG/SVG visualizations.

Installation

  • Ubuntu/Debian: sudo apt install duc (via universe repo).
  • Fedora/RHEL: sudo dnf install duc
  • Arch Linux: sudo pacman -S duc

Usage Example

  1. Build an index for /home:
    duc index /home  
  2. Query the cache with a terminal interface:
    duc ui /home  
  3. Generate an HTML report:
    duc report /home > disk_usage.html  

duc HTML Report
Sample HTML report generated by duc.

Pros and Cons

ProsCons
Blazing-fast queries after initial indexRequires manual index updates (not real-time).
Multiple output formats (terminal, GUI, web)Initial index scan can be slow on large directories.
Lightweight cache (uses minimal disk space)Less intuitive than GUI tools for casual users.

7. Bonus: Enhancing df and du with Visualization Tips

While df and du are not visual tools, you can combine them with command-line utilities to add context. Here are some useful tricks:

1. Sort du Output by Size

List the 20 largest files/directories in /var:

du -a /var | sort -n -r | head -20  
  • -a: Show all files (not just directories).
  • -n -r: Sort numerically in reverse order (largest first).

2. Human-Readable df with sort

Show disk usage by mounted volume, sorted by size:

df -h | sort -k5 -h  
  • -h: Human-readable (GB, MB).
  • -k5 -h: Sort by the 5th column (used space) numerically.

3. Generate a Simple Bar Chart with gnuplot

For a basic visual, pipe du output to gnuplot:

du -sh /home/* | awk '{print $1, $2}' | gnuplot -p -e "set terminal dumb; set title 'Disk Usage'; plot '-' using 1:xtic(2) with boxes"  

This generates an ASCII bar chart in the terminal.

8. Tool Comparison Table

ToolTypeVisualizationSpeedBest For
ncduCLIText-based treeFastServers, minimal systems, SSH environments
FilelightGUISunburst (ring)ModerateKDE desktop users, circular visual fans
BaobabGUITreemap/ringModerateGNOME desktop users, remote scans
QDirStatGUITreemap (color-coded)ModerateFile type analysis, bulk cleanup
gduCLIText-based treeVery FastLarge directories, performance-focused
ducCLI/GUICache + multipleFast (cached)Repeated scans, reporting/scripting

9. Conclusion

Choosing the right disk usage visualization tool depends on your workflow:

  • Terminal/Server Users: Opt for ncdu (mature, widely available) or gdu (faster for large data).
  • Desktop Users: Use Filelight (KDE), Baobab (GNOME), or QDirStat (color-coded file types).
  • Repeated Scans/Reporting: duc’s cached indexes save time for frequent analysis.

All these tools transform raw disk usage data into actionable insights, making it easier to free up space and keep your Linux system running smoothly.

10. References