14 iotop command examples [Monitor Disk IO]

Introduction to iotop command

iotop is a short form for Input/Output top and is similar to top command in Linux. iotop is a useful command that allows the user to monitor I/O usage in the disk. It provides the list of all I/O operations by the processes or threads in the Linux system.

iotop program is designed with Python and requires Kernel for executing and monitoring I/O usage details. Only the root user can run iotop command. System administrations can use it to find particular processes with high I/O read and write in the disk.

Advertisement

 

iotop command requirements

To execute iotop command, the following programs are must:

  • Python 2.7 or higher
  • Kernel 2.6.20 or higher

You can check the Python version in the terminal by using command python --version.

$ python --version
Python 2.7.12

To check the Kernel version, use the command uname -r.

$ uname -r
4.15.0-142-generic

If the output version is lower than the required version, use sudo apt-get update to get the latest version of all installed packages and their dependencies.

$ sudo apt-get update

 

How to install iotop

Before using iotop command, you have to install it in the system.

 

Install iotop in Ubuntu, Debian and Linux Mint

$ sudo apt-get install iotop

 

Install iotop in CentOS, RHEL, Rocky Linux and Fedora

$ sudo yum install iotop

 

Different examples to use iotop command

iotop command requires root privileges so you can either log in as a root user or use sudo in front of iotop command to execute it.

Advertisement

In this article, you will learn how to use iotop command and monitor the disk I/O usage details in the Linux system.

 

1. Get the iotop version

sudo iotop --version is a simple command that can be used to get the version detail of iotop program. As you can see in the output above, 0.6 is the version of iotop.

$ sudo iotop --version
0.6

 

2. Check the details of disk I/O usage using iotop command

You can execute iotop without any additional argument:

$ sudo iotop

Sample Output:

iotop command output

This command allows the user to monitor the details of I/O usage on the disk.

  • TID indicates the thread ID and PID indicates the process ID.
  • PRIO is the I/O priority at which the thread is running.
  • USER provides the user owner for the respective process.
  • DISK READ / WRITE displays the bandwidth of reading and writing data in the disk by processes or threads in the system.
  • SWAPIN and IO shows the percentage of time spent by processes or threads while swapping in and waiting on IO operations respectively.

The total disk read and write bandwidth are displayed in the top of the output. The actual disk read and write shows the bandwidth of processes or threads that are actually doing I/O. The total and actual disk read/write values may not be equal at any given time because of data caching and I/O operations reordering in the Linux kernel.

To stop displaying the output, press q.

 

3. Display processes that are actually doing disk I/O using iotop command

sudo iotop -o command allows you to filter the list of the output and displays only the running I/O operations by processes or threads. The output below shows the processes or threads that are actually doing I/O operations.

Advertisement
$ sudo iotop -o

Sample Output:

output displayed by command iotop -o

 

4. Get the output in non-interactive or batch mode using iotop command

This command displays the output in non-interactive mode or batch mode. Generally, the output shown by iotop command is in the interactive mode.

The output displayed in non-interactive mode cannot be intervened unless you kill the program by pressing Ctrl+c.

$ sudo iotop -b

Sample Output:

output dislayed by iotop -b command

 

5. Get disk I/O details of a particular process with iotop command

sudo iotop -p command requires a number as an argument that denotes the process ID. This command allows the user to see the particular process with process ID.

For example, if you use sudo iotop -p 22 then it will display only the I/O operation with Process ID 22.

$ sudo iotop -p 22

Sample Output:

output displayed by command iotop -p 22

 

6. Set the number of iterations with iotop command

iotop -n command also takes a number as an argument which indicates the iterations to be done in the output. It updates the output for a fixed number of times before quitting the program.

For example, if you use iotop -n 7 then the output will be updated for only 7 times. The default time is infinite so the program never quits on its own.

Use this code in your terminal to get the desired output.

$ sudo iotop -n 7

 

7. Display the accumulated disk I/O with iotop command

Use -a argument with iotop. It displays the accumulated I/O instead of the bandwidth. It shows the amount of I/O processes done since iotop started.

$ sudo iotop -a

Sample Output:

output displayed by command iotop -a

 

8. Display user specific disk I/O usage

It takes an argument of existing user in the system to monitor the details of that user. It displays the processes or threads operated by a specific user.

For example, if you use sudo iotop -u home then the I/O usages by user home are only displayed.

$ sudo iotop -u

Sample Output:

output displayed by command iotop -u home

 

9. Display the output with timestamp using iotop command

Use -t argument with iotop command. It displays the output with timestamp in each line. Each line will have a current time.

$ sudo iotop -t

Sample output:

output displayed by command iotop -t

 

10. Get details of processes only with iotop command

This command helps you to monitor the I/O usage by processes only. Normally, the output contains all the threads. In the output below, you can see the column PID which indicates the process ID.

$ sudo iotop -P

Sample Output:

output displayed by iotop -P command

 

11. Hide some lines of header with iotop command

Use -q argument with iotop. It is used to hide some lines of header in the output. The top of the interface will disappear on the output.

$ sudo iotop -q

Sample Output:

output displayed by command iotop -q

 

12. Show disk IO usage in KB with iotop command

Use -k argument with iotop command which displays the bandwidth in kilobytes only. Normally, it is shown in bytes, kilobytes and megabytes depending upon the size.

$ sudo iotop -k

As you can see in the output below, the file larger than 1024 kilobytes is also shown in the unit kilobytes.

output displayed by iotop -k command

 

13. Delay the iotop command output

Use iotop command with -d argument to provide the numerical value using which the iotop should delay the output. It takes an argument as a number for the time in seconds.

For example, if you use sudo iotop -d 8, then the details will update every 8 seconds only in the output. Use this code in your terminal to get the desired output.

$ sudo iotop -d 8

 

14. Display help message of iotop command

This is the basic command in Linux to get the help message.

$ sudo iotop -h

Sample Output:

output displayed by iotop -h command

 

Controls in iotop tool

These are the keyboard shortcuts in iotop tool which can be used in the output displayed in the interactive mode.

  1. Use left or right arrows to change the sorting
  2. Use r to invert the sorting order
  3. Press o to see processes or threads that are actually doing I/O
  4. Press p to see only processes instead of all threads
  5. Press a to display the accumulated I/O instead of bandwidth
  6. Press q to stop displaying the output

 

Conclusion

These are some example of using iotop commands in the Linux. iotop is a very useful tool to track down the processes or threads which are causing high IO usage in the disk.

 

What's Next

You can explore Top 15 tools to monitor disk IO performance with examples

 

Further Reading

man page for iotop command

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment