iotop Command in Linux with Examples
The 'iotop' command is a powerful Linux tool designed for monitoring disk Input/Output (IO) usage in real-time. It provides a comprehensive view of the current disk IO activities by processes, making it invaluable for system administrators who need to track down processes that are causing high disk IO, potentially impacting system performance. Written in Python, 'iotop' requires specific kernel modules and a Python interpreter for execution, typically needing root privileges.
This tool’s functionality is similar to the top command, but it specifically focuses on disk IO operations. With 'iotop', you can easily identify processes that are reading from or writing to disk, allowing for efficient troubleshooting of performance issues related to disk IO.
Installation of iotop
1. For CentOS/RHEL
sudo yum install iotop
2. For ubuntu
sudo apt install iotop
How to Use the 'iotop' Command
1. List Processes and Their Current Disk IO Usage
To get the list of processes and their current disk IO usage.
sudo iotop

This command will now display the list of processes and their current disk usage and will keep on updating the same.
2. Show Processes Actually Performing IO Operations
To show processes that are actually doing IO
sudo iotop -o

This will display all the processes which are currently and actually doing IO.
3. Check the Version of iotop
To get the version of the 'iotop'
sudo iotop --version

This will display the currently installed version of iotop tool.
4. Display Help Information
To display help section
sudo iotop -h

This command will display the help section of the iotop tool.
5. Run iotop in Non-Interactive Mode
To display output in non interactive mode
sudo iotop -b

This will display the output in non-interactive and batch mode.
6. Limit the Number of Updates
To change the number of iterations or updations
sudo iotop -n 3

This command will not update the output 3 times in spite of the default time which is infinity.
7. Display IO Usage for a Specific Process
To monitor a specific process by its PID, use:
sudo iotop -p 10989

This will display the IO usage of the process with the mentioned PID in spite of all the processes.
8. Show Accumulated IO Usage Over Time
To show accumulated output
sudo iotop -a

This will not display the accumulated IO instead of bandwidth.
9. Add Timestamps to the Output
To add a time stamp to each line
sudo iotop -t

This will add a time stamp to each line of the output.
10. Suppress Header Lines for a Cleaner Output
To suppress some lines of header
sudo iotop -q

This will now suppress some line of header in the output.
Conclusion
The iotop command is a valuable tool for Linux system administrators who need to keep an eye on disk IO usage. It shows real-time information about which processes are accessing the disk, making it easier to spot and fix any performance issues related to high disk IO.
By learning the different commands and options that iotop offers, you can customize your monitoring to fit your specific needs, whether it’s viewing real-time data interactively or logging information with timestamps for later review. Using iotop regularly as part of your system maintenance can help you keep disk usage in check, catch potential problems early, and keep your system running smoothly.