YouTip LogoYouTip

Linux Comm Iotop

[![Image 1: Linux Command Encyclopaedia](#) Linux Command Encyclopaedia](#)\n\n* * *\n\niotop is a Linux system monitoring tool similar to the top command, but it focuses on displaying disk I/O usage. It can monitor the disk read/write activities of various processes in the system in real-time, helping system administrators identify I/O-intensive processes.\n\nUnlike tools such as iostat, iotop provides process-based I/O monitoring, which can pinpoint the read/write speed and cumulative I/O amount for each process.\n\n* * *\n\n## Installing iotop\n\nMost Linux distributions do not have iotop installed by default and require manual installation:\n\n## Examples\n\n# Debian/Ubuntu systems\n\nsudo apt-get install iotop\n\n# RHEL/CentOS systems\n\nsudo yum install iotop\n\n# Fedora systems\n\nsudo dnf install iotop\n\n# Arch Linux\n\nsudo pacman -S iotop\n\n* * *\n\n## Basic Syntax\n\nThe basic command format for iotop is as follows:\n\nsudo iotop \nNote: iotop requires root privileges to run because it needs to access the kernel's I/O statistics.\n\n* * *\n\n## Common Option Parameters\n\n| Option | Description |\n| --- | --- |\n| `-o` or `--only` | Only show processes that are actually performing I/O operations |\n| `-b` or `--batch` | Non-interactive mode, suitable for use in scripts |\n| `-n NUM` | Number of iterations to run in non-interactive mode |\n| `-d SEC` | Set the refresh interval in seconds |\n| `-p PID` | Only monitor the process with the specified PID |\n| `-u USER` | Only monitor processes for the specified user |\n| `-P` or `--processes` | Only show processes, not threads |\n| `-a` or `--accumulated` | Show cumulative I/O instead of bandwidth |\n| `-k` or `--kilobytes` | Use KB/s instead of B/s as the unit |\n| `-t` or `--time` | Add timestamp to output |\n| `-q` or `--quiet` | Reduce header information (automatically enabled in non-interactive mode) |\n\n* * *\n\n## Keyboard Shortcuts in Interactive Mode\n\nIn interactive mode, iotop supports the following keyboard operations:\n\n| Shortcut | Function |\n| --- | --- |\n| Left/Right arrows | Change the sorting field |\n| r | Reverse sorting |\n| o | Only show active I/O processes (equivalent to -o option) |\n| p | Toggle process/thread display mode |\n| a | Toggle cumulative/real-time display mode |\n| q | Quit iotop |\n| i | Change priority filter (only show processes with higher priority) |\n| Any key | Force refresh the display |\n\n* * *\n\n## Output Field Explanation\n\niotop's output contains multiple fields, with each field meaning as follows:\n\n1. **TID/PID**: Thread ID/Process ID\n2. **PRIO**: I/O priority (Linux's ionice value)\n3. **USER**: Process owner\n4. **DISK READ**: Disk read speed\n5. **DISK WRITE**: Disk write speed\n6. **SWAPIN**: Swap space usage percentage\n7. **IO>**: I/O percentage\n8. **COMMAND**: Process name\n\n* * *\n\n## Usage Examples\n\n### Example 1: Basic Monitoring\n\nsudo iotop\nThis will launch the interactive interface, showing I/O activity for all processes, sorted by I/O usage.\n\n### Example 2: Only Show Active I/O Processes\n\nsudo iotop -o\nOr press the `o` key after running iotop to only show processes currently performing I/O operations.\n\n### Example 3: Monitor Processes for a Specific User\n\nsudo iotop -u apache\nOnly monitor I/O activity for processes owned by user apache.\n\n### Example 4: Non-Interactive Mode Output\n\nsudo iotop -b -n 3 -d 2\nRun in non-interactive mode, refresh every 2 seconds, and exit after outputting results 3 times.\n\n### Example 5: Monitor a Specific Process\n\nsudo iotop -p 1234\nOnly monitor I/O activity for the process with PID 1234.\n\n* * *\n\n## Practical Application Scenarios\n\n### Scenario 1: Identifying the Cause of System Slowdown\n\nWhen the system response becomes slow, run:\n\nsudo iotop -o\nThis can quickly identify which processes are heavily reading/writing to disk, causing the system I/O bottleneck.\n\n### Scenario 2: Monitoring Database Performance\n\nFor database servers like MySQL:\n\nsudo iotop -u mysql -o\nSpecifically monitor I/O activity for the mysql user to analyze the database's disk load.\n\n### Scenario 3: Periodic I/O Logging\n\nsudo iotop -b -t -n 5 -d 10 > iotop_log.txt\nRecord I/O status every 10 seconds, for a total
← Linux Comm GlancesLinux Comm Dos2Unix β†’