Understanding iostat Command and Examples in Linux
What is iostat command?
The iostat command is one of the main tools used in Linux for analyzing I/O (Input/Output) performance. This command reports a variety of information about the system’s CPU utilization and hard disk I/O including device utilization, throughput, average queue size, transfer rate and percentage of CPU time spent in servicing disk I/O.
How to use iostat command?
The syntax for using the iostat command is as follows:
iostat [-c | -d] [-t] [-h] [device list] [interval] [count]
Where:
- -c - Displays CPU statistics
- -d - Displays device statistics
- -t - Displays extended statistics
- -h - Displays help info
- device list - List of devices to gather statistics from
- interval - How often to report statistics (in seconds)
- count - Number of times to report
Examples of iostat command
Here are some examples of how to use the iostat command:
- To display CPU and device utilization statistics for all devices, run the following command:
iostat
- To display extended statistics for all devices, run the following command:
iostat -t
- To display statistics for device sda every 5 seconds, 3 times, run the following command:
iostat -d sda 5 3