iostat Command in Linux
iostat Command in Linux

iostat Command in Linux

The iostat command in Linux is a powerful utility that provides detailed statistics about CPU and disk I/O performance. It helps system administrators analyze system performance, troubleshoot bottlenecks, and optimize resource usage. By monitoring CPU usage, disk throughput, and device utilization, iostat enables users to gain insights into system behavior over time.

In this article, we will explore how to use iostat in Linux, its installation process, syntax, examples, and advanced usage scenarios to monitor CPU and disk performance effectively.

Installing iostat in Linux

The iostat command is part of the sysstat package, which provides a collection of performance monitoring tools. To install it, follow these steps based on your Linux distribution:

Install iostat on Ubuntu/Debian

sudo apt update
sudo apt install sysstat -y        

Install iostat on CentOS/RHEL

sudo yum install sysstat -y        

Install iostat on Fedora

sudo dnf install sysstat -y        

Enable sysstat Service (if required)

Some distributions require enabling the sysstat service to collect system performance data.

sudo systemctl enable sysstat
sudo systemctl start sysstat        

Once installed, verify the installation by running:

iostat --version        

Also Read:- linux video capture software

Basic Syntax of iostat

The general syntax of the Linux iostat command is:

iostat [options] [interval] [count]        

Where:

  • options: Modifies output display (e.g., CPU, device statistics).
  • interval: The time in seconds between each report.
  • count: The number of reports to display.

Example:

iostat 5 3        

This will display system statistics every 5 seconds, three times.

Understanding iostat Output

Running iostat without options provides CPU and device utilization statistics:

Sample Output:

Linux 5.10.0-8-amd64 (server) 			 03/20/2025 

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          10.50    0.00    5.30    2.80    0.00   81.40

device           tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda              32.5       1024.5       512.3    1050000     525000        

Key Metrics:

  • CPU Metrics:
  • Disk Metrics:

Practical Examples of iostat Command

Display CPU Usage Only

iostat -c        

Display Disk Usage Only

iostat -d        

Continuous Monitoring Every 2 Seconds

iostat 2        

Show Extended Disk Statistics

iostat -x 5 3        

Display Statistics for a Specific Device

iostat -p sda        

Also Read:- best linux distro for security

Monitoring CPU and Disk Performance with iostat

Monitoring CPU Utilization

Use the following command to monitor CPU performance over time:

iostat -c 3 5        

This command prints CPU utilization every 3 seconds, five times.

Monitoring Disk Performance

To check iostat disk performance, use:

iostat -dx 2 5        

This provides extended disk I/O statistics at 2-second intervals.

Advanced Usage of iostat Command

Generating JSON Output

Some Linux distributions allow exporting iostat data in JSON format for integration with monitoring tools:

iostat -o JSON        

Collecting Reports for System Performance Analysis

Save iostat output to a file for later analysis:

iostat -c -d 10 60 > performance_report.txt        

This logs CPU and disk performance every 10 seconds, for 60 iterations.

Common Use Cases for System Administrators

Detecting CPU Bottlenecks

  • High %iowait values indicate disk performance issues.
  • High %user and %system usage suggests CPU-intensive applications.

Analyzing Disk Performance Issues

  • Check tps (transactions per second) for high disk activity.
  • Compare kB_read/s and kB_wrtn/s to identify excessive disk reads or writes.

Optimizing System Resources

  • Use iostat alongside vmstat and sar for complete system monitoring.
  • Schedule periodic reports using cron jobs:

crontab -e
*/10 * * * * /usr/bin/iostat -c -d >> /var/log/iostat.log        

This runs iostat every 10 minutes and appends data to a log file.

Also Read:- oracle linux vs redhat

Troubleshooting Performance Issues with iostat

High %iowait Values

  • Check if storage devices are overloaded.
  • Consider optimizing disk read/write operations or using faster storage.

High CPU Usage

  • Investigate processes using top or htop.
  • Identify if a specific service is consuming excessive CPU resources.

Disk Performance Lag

  • Compare disk performance with iostat -dx 5.
  • Optimize I/O-intensive workloads by adjusting disk scheduling algorithms.

Frequently Asked Questions (FAQs)

What is the iostat command used for?

The iostat command is used to monitor system input/output statistics, including CPU utilization and disk performance. It helps diagnose performance bottlenecks and optimize resource usage.

How do I install iostat on Linux?

You need to install the sysstat package using:

  • Ubuntu/Debian: sudo apt install sysstat
  • CentOS/RHEL: sudo yum install sysstat
  • Fedora: sudo dnf install sysstat

How do I check CPU usage with iostat?

Run:

iostat -c        

This displays CPU usage statistics.

How can I monitor disk performance with iostat?

Use:

iostat -dx 5        

This provides detailed disk I/O statistics at 5-second intervals.

Can iostat be used for real-time monitoring?

Yes, you can run:

iostat 2        

This updates the statistics every 2 seconds in real-time.

Conclusion

The iostat command in Linux is an essential tool for monitoring CPU and disk performance. By using iostat Linux examples, system administrators can efficiently diagnose performance bottlenecks, troubleshoot resource utilization issues, and optimize server performance.

Regular use of iostat ensures proactive system monitoring, helping to maintain optimal performance in Linux environments.

To view or add a comment, sign in

More articles by Vivek Yadav

  • How Can I Make Video From Photos

    How Can I Make Video From Photos is one of the most common questions in 2026 as AI technology continues to simplify…

  • How to Make a Picture Talk Using AI

    How to Make a Picture Talk Using AI is one of the most popular AI-driven techniques in 2026, allowing users to…

  • How Do You Make A Picture Talk

    How Do You Make A Picture Talk is a common question in 2026 as AI-powered video tools continue to transform content…

  • Create Talking Video From Photo

    Learning how to Create Talking Video From Photo has become an essential part of modern AI content creation in 2026…

  • How to Make Picture Talk

    Learning How to Make Picture Talk has become one of the most popular AI-driven content creation trends in 2026. This…

  • AI Video Generator Lip Sync

    AI Video Generator Lip Sync refers to advanced AI systems that create videos by synchronizing speech with realistic…

  • Lip Sync Video Maker

    Lip Sync Video Maker is an AI-powered tool that automatically matches spoken audio with realistic lip movements in…

  • Make an Image Talk with AI

    Make an Image Talk with AI in 2026 refers to advanced artificial intelligence tools that transform static images into…

  • Photo to Talking Video AI

    The rise of Photo to Talking Video AI in 2026 has transformed how users convert static images into dynamic, engaging…

  • Lip Sync Video Generator

    A Lip Sync Video Generator is an AI-powered tool that creates videos where speech is accurately synchronized with mouth…

Others also viewed

Explore content categories