On Debian how to monitor `du -sh` progress?
Jul 13, 11:12am

On Debian (and most Linux systems), the du command itself does not natively show progress while calculating disk usage. However, you can use alternative tools or workarounds to monitor progress. Here are the best options:


1. Use pv (Pipe Viewer)

pv is a command-line tool that monitors the progress of data through a pipe. You can combine it with du to estimate progress.

Install pv:

bash
sudo apt update && sudo apt install pv

Usage:

bash
find /path/to/directory -type f -print0 | pv -l -s $(find /path/to/directory -type f | wc -l) | xargs -0 du -sh
  • This counts the number of files first, then uses pv to show progress as du processes them.
  • Limitation: This only shows progress for file counting, not actual disk usage calculation.

2. Use ncdu (NCurses Disk Usage)

ncdu is a more interactive and user-friendly alternative to du. It shows progress as it scans directories.

Install ncdu:

bash
sudo apt update && sudo apt install ncdu

Usage:

bash
ncdu /path/to/directory
  • ncdu will scan the directory and show a progress bar.
  • After scanning, you get an interactive interface to explore disk usage.

3. Use gdu (Fast Disk Usage Analyzer)

gdu is a modern, fast alternative to du with a progress bar.

Install gdu:

bash
sudo apt update && sudo apt install gdu

Usage:

bash
gdu /path/to/directory
  • gdu shows a progress bar as it scans.

4. Use progress (Linux Process Progress Viewer)

The progress tool can monitor the progress of coreutils commands like du.

Install progress:

bash
sudo apt update && sudo apt install progress

Usage:

Run du in one terminal:

bash
du -sh /path/to/directory

In another terminal, run:

bash
progress -w
  • This will show the progress of du if it supports it (works best with dd, cp, etc., but may not always work with du).

5. Use ionice and nice for Background Monitoring

If you just want to run du in the background and check its progress occasionally, you can use:

bash
ionice -c 3 nice -n 19 du -sh /path/to/directory > du_progress.log &
tail -f du_progress.log
  • This runs du with low priority and logs output to a file.
  • Use tail -f to monitor the log in real-time.

Summary Table

Tools for Monitoring `du` Progress
pv
Yes
No
sudo apt install pv
Works with file counting
ncdu
Yes
Yes
sudo apt install ncdu
Best for interactive use
gdu
Yes
Yes
sudo apt install gdu
Fast, modern alternative
progress
Sometimes
No
sudo apt install progress
Works best with other commands

Recommendation: For a progress bar and interactive exploration, use ncdu or gdu. For a simple progress bar, use pv.

Jul 13, 11:12am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more