iostat command is used to find CPU usage and other connected Input/Output devices.
- iostat command is useful for evaluating the performance of I/O devices, and their efficiency.
- It is also helpful for monitoring CPU Usage.
How to Install iostat command?
By default, iostat command is already installed in Linux/Unix. If it is not installed, you can install iostat command using the following command.
For fedora/ Red Hat/ CentOS
yum install sysstat
For Ubuntu / Debian / Linux Mint
sudo apt-get install sysstat
Syntax for iostat command
iostat [option] [device-name]
Uses of iostat command with example
CPU utilization report
iostat command without any argument display CPU utilization report.
Display report in Human readable format
Display CPU usage only
By default iostat command displays reports of CPU and I/O device. But, you can restrict the iostat command to display CPU usage only. To display CPU usage only, use
iostat -c command.
Display CPU usage only at a fixed time interval
You can also restrict iostat command to automatically display only CPU usage reports at a fixed time interval. To display CPU usage reports at a fixed time interval, follow the following syntax.
iostat -c INT
Here INT is a fixed time interval in seconds. Do not forget to change INT with your desired time interval. Here I am using 20 for INT. So, my final command will be
iostat -c 20. This command will display the CPU usage report every 20 seconds interval.
iostat -c 20
Display I/O device report in MegaBytes
Display I/O device report in KiloBytes
Display I/O device report in KiloBytes at fixed time interval
iostat -k 20
Display the report of block devices
Display the report of block devices in MegaBytes
iostat -d sda7 sda6 2 3
iostat -j ID mmcbkl0 sda6 -x -m 3 2
iostat -o JSON