Terminal GuideTerminal Guide

iotop

System Monitoring
Linux
Python

I/O monitor showing disk read/write by process.

Official Website

Features

Disk I/OPer-processReal-timeSorting

Installation

APT (Debian/Ubuntu)
apt install iotop
Pacman (Arch)
pacman -S iotop
DNF (Fedora)
dnf install iotop

Why Use iotop?

Per-Process I/O Tracking

See exactly which processes are reading from and writing to disk, including real-time rates and accumulated totals.

Real-Time Performance Insight

Monitor disk I/O performance in real-time to identify processes causing I/O bottlenecks and performance issues.

Simple and Focused

Specialized tool dedicated to disk I/O monitoring. Lightweight and easy to use with minimal overhead.

Interactive Filtering & Sorting

Filter by process, sort by different metrics, and focus on high I/O consumers to quickly identify problem processes.

Installation

installation
# Ubuntu/Debian
sudo apt install iotop

# Fedora/RHEL
sudo dnf install iotop

# Arch Linux
sudo pacman -S iotop

# CentOS
sudo yum install iotop

# Verify installation
iotop --version

# Note: iotop requires root/sudo privileges to run

Basic Usage

basic-usage
# Start iotop (requires root)
sudo iotop

# Run in batch mode (non-interactive, outputs once)
sudo iotop -b

# Run in batch mode for 5 iterations with 1-second delay
sudo iotop -b -n 5 -d 1

# Monitor for a specific duration
sudo iotop -b -n 10 -d 2 > iotop_output.txt

# Only show processes with I/O activity
sudo iotop -o

# Show accumulated I/O instead of bandwidth
sudo iotop -a

# Get help
iotop -h

Key Options & Interactive Commands

Command Line Options

OptionDescription
-b, --batchNon-interactive batch mode
-o, --onlyOnly show processes with I/O activity
-a, --accumulatedShow accumulated I/O instead of bandwidth
-n NUM, --iter NUMNumber of iterations in batch mode
-d SEC, --delay SECDelay between iterations (in seconds)
-p PID, --pid PIDMonitor specific process by PID
-u USER, --user USERShow only processes for specific user

Interactive Mode Shortcuts

KeyFunction
oToggle showing processes with only I/O activity
aToggle between accumulated I/O and bandwidth
rReverse sorting order
pSort by PRIO (I/O priority)
qQuit iotop

Practical Examples

1. Find High I/O Processes

example-find-high-io
# Start interactive monitoring
sudo iotop

# Key tips:
# - Processes are sorted by I/O bandwidth by default
# - Top processes are the heaviest I/O consumers
# - Press 'o' to show only processes with I/O
# - Press 'r' to reverse sort order

2. Monitor Specific Process

example-specific-process
# Monitor specific process by PID
sudo iotop -p 1234

# Monitor processes owned by specific user
sudo iotop -u www-data

# Monitor multiple processes
sudo iotop -p 1234,5678

3. Batch Mode for Logging

example-batch-mode
# Capture I/O data for analysis
sudo iotop -b -n 100 -d 5 > iotop_log.txt

# Background collection every minute
nohup bash -c 'while true; do echo "=== $(date) ===" >> iotop.log;   sudo iotop -b -n 1 -d 1 >> iotop.log; sleep 60; done' &

# Capture only active processes
sudo iotop -b -n 60 -d 1 -o > active_io.txt

4. Find Disk Hogs

example-disk-hogs
# Show accumulated I/O (total data transferred)
sudo iotop -a

# Show only processes with I/O + accumulated view
sudo iotop -o -a

# Find top 10 I/O processes and save to file
sudo iotop -b -n 5 -d 2 | head -20 > top_io.txt

5. Troubleshooting High Load

example-troubleshooting
# Monitor during high load periods
watch -n 1 'sudo iotop -b -n 1 | head -20'

# Run continuously and log with timestamps
sudo bash -c 'while true; do   echo "[$(date '+%Y-%m-%d %H:%M:%S')]" >> io_analysis.log;   iotop -b -n 1 -d 1 | head -15 >> io_analysis.log;   echo "---" >> io_analysis.log;   sleep 60; done' &

Understanding the Output

Column Meanings

TID

Thread ID - identifies the thread/process

PRIO

I/O Priority (be* prefix means best-effort, rt* means real-time)

USER

User who owns the process

DISK READ

Current disk read rate (bandwidth mode) or total read (accumulated mode)

DISK WRITE

Current disk write rate (bandwidth mode) or total write (accumulated mode)

SWAPIN

Percentage of memory swapped to disk

IO

Percentage of time the process spent doing I/O

COMMAND

Command name and arguments

Example Output

example-output
Total DISK READ:       10.25 M/s | Total DISK WRITE:       5.13 M/s
Current DISK READ:      8.50 M/s | Current DISK WRITE:      3.25 M/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND
 1234 be/4 mysql      8.50 M/s   2.30 M/s  0.00%  95.23% mysqld
 5678 be/4 postgres   0.00 B/s   0.95 M/s  0.00%  45.67% postgres
 9012 be/4 root       0.00 B/s   0.00 B/s  0.00%   0.00% kernel

Tips

1. Root Privileges Required

iotop requires root access to read kernel I/O data. Always use 'sudo iotop' or add it to sudoers for passwordless access if needed.

2. Combine with watch for Continuous Monitoring

Use 'watch -n 1 "sudo iotop -b -n 1"' to continuously monitor I/O in a terminal without running iotop interactively.

3. Pipe Output for Analysis

Use batch mode with piping: 'sudo iotop -b -n 1 | grep mysql' to filter specific processes or integrate with monitoring scripts.

4. Monitor During Peak Hours

Use iotop during times when system is experiencing performance issues to identify I/O-related problems quickly.

5. Check I/O Priority Classes

The PRIO column shows I/O priority classes. Lower priority processes don't monopolize disk access. Use ionice to adjust priorities if needed.

6. Use Accumulated Mode for Long-Term Trends

Switch to accumulated mode (-a) to see total I/O since process start, helping identify which processes transfer the most data over time.

Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More