Linux pv Command Guide: Monitor and Throttle Data Pipelines
In modern Linux environments, many commands such as cat, gzip, tar, and dd run silently. They perform large data transfers without showing progress, speed, or estimated completion time.
The pv (Pipe Viewer) utility solves this limitation by inserting a real-time monitoring layer inside your pipeline. It acts like a digital flow meter — measuring data as it moves without modifying the stream itself.
🔍 How pv Works: The Digital Flow Meter
#
Think of pv as a transparent inspection window placed inside a Unix pipe. Data flows through it unchanged, but pv calculates and displays:
- Progress percentage
- Transfer speed
- Elapsed time
- Estimated time remaining
- Total bytes transferred
Because it operates purely on standard input and output, it integrates seamlessly into existing pipelines.
Installation #
If pv is not installed:
# Debian / Ubuntu
sudo apt install pv
# RHEL / Fedora
sudo dnf install pv
Verify installation:
pv --version
⚙️ Common Usage Patterns #
Basic File Monitoring #
When pv reads a regular file, it automatically detects the file size and can display accurate progress and ETA:
pv large_backup.sql > /dev/null
Example output:
252MiB 0:00:04 [61.4MiB/s] [===============> ] 25% ETA 0:00:12
This is useful for benchmarking disk throughput or validating read performance.
Using pv Inside a Pipeline
#
When inserted between two commands, pv monitors throughput in real time:
cat access.log | pv | gzip > access.log.gz
If the total size is unknown (such as a stream), pv will still show:
- Current transfer rate
- Elapsed time
- Total bytes processed
However, percentage and ETA will not appear unless size is specified.
Forcing a Known Size with -s
#
If you know the total expected size of the data stream, you can manually provide it:
# Imaging a 4GB drive
sudo dd if=/dev/sdb | pv -s 4g | dd of=drive_backup.img
This enables:
- Full progress bar
- Accurate ETA
- Percentage tracking
🛠 Advanced Options Reference #
| Option | Long Form | Description |
|---|---|---|
-p |
--progress |
Show progress bar |
-t |
--timer |
Show elapsed time |
-e |
--eta |
Show estimated completion time |
-r |
--rate |
Show transfer speed |
-b |
--bytes |
Show total bytes transferred |
-L |
--rate-limit |
Limit transfer speed (e.g., -L 2m) |
-s |
--size |
Specify total data size |
You can combine options:
pv -ptrb large_file.iso > /dev/null
🚀 Real-World Practical Scenarios #
Throttling Data Transfers #
To prevent saturating network or storage bandwidth:
# Limit transfer to 10MB/s
pv -L 10m large_file.iso > /remote/nfs/share/file.iso
This is especially useful in shared infrastructure or production systems.
Monitoring Remote Transfers over SSH #
Track how fast data is sent to a remote server:
tar -czf - ./my_folder | pv | ssh user@server "cat > backup.tar.gz"
This provides real-time visibility into:
- Compression speed
- Network throughput
- Total transferred data
Monitoring Disk Imaging with Detailed Stats #
sudo dd if=/dev/nvme0n1 bs=4M | pv -ptrb | dd of=disk_image.img
This displays:
- Progress
- Timer
- Rate
- Bytes transferred
Ideal for system migration or backup operations.
⚠️ Limitations to Keep in Mind #
- No
mvsupport: If moving files within the same filesystem,mvonly updates metadata. No data stream exists forpvto monitor. - High-Speed Bottlenecks: On ultra-fast NVMe storage (10GB/s+),
pvmay introduce slight CPU overhead due to terminal rendering. - Encrypted Streams:
pvmeasures raw data flow. It cannot inspect encrypted or compressed content internally.
📋 Quick Command Reference #
| Goal | Command | ||
|---|---|---|---|
| Simple speed test | pv file > /dev/null |
||
| Compress with progress | `cat file | pv | gzip > file.gz` |
| Copy disk image | pv -ptrb /dev/sdb > image.img |
||
| Throttle copy speed | pv -L 1m source > destination |
🧠 Final Perspective #
The power of pv lies in its simplicity. It does not replace core Linux utilities — it enhances them.
By inserting real-time visibility into data pipelines, pv transforms blind transfers into observable, controllable operations — a critical capability in modern DevOps, storage engineering, and infrastructure management.
In 2026, despite advances in monitoring systems and GUI tools, pv remains one of the most elegant and practical Unix utilities for understanding data flow at the command line.