Check CPU usage with top command in Linux

Table of Contents


CPU usage in top command is an important metric for CPU performance in Linux. Today we will learn how to use top command to check cpu usage and what us sy ni wa hi st means. Then we can get an idea of which column uses the most CPU resource.

Understanding CPU usage in Linux

The CPU usage is a statistic of CPU usage per unit time, displayed as a percentage. Linux is a multitasking OS, which divides the time of each CPU into very short time slices, and then allocates them to each task in turn through the scheduler, thus creating the illusion of multitasking running at the same time.

Understanding top command in Linux

The top command is a great tool for checking CPU usage in Linux. It gives you a quick overview of how much CPU each process is using. This can be helpful for identifying which processes are using the most CPU and determining if there is anything that can be done to reduce the load.

The top command is used to display the processes that are currently running on a Linux system. It can be used to show information about CPU usage, memory usage, and load average.

How to use top command in Linux to check CPU usage?

The best way to check cpu usage in Linux is using top command. Simply type “top” at the command prompt. You will then see a list of the processes that are currently running, as well as information about the CPU usage, memory usage, and load average. To exit the top command, press the q key.

Here are some other useful options for the top command:

  • -h : Show help
  • -d : Delay between updates (in seconds)
  • -s : Sort by CPU usage
  • -m : Sort by memory usage
  • -p : Processes to show (by PID)
  • -u : User to show

Check CPU Usage in Linux – us sy ni id wa

  • us: Time spent in running user space processes. This reflects the CPU consumption by your application.
  • sy: Time taken by system processes. A higher number here can indicate too many processes, and the CPU is spending more time process scheduling.
  • ni: Time spent with user space processes that are assigned with execution priority (nice value).
  • id: Indicates the time spent in idle mode, where the CPU is doing nothing.
  • wa: Waiting for IO. A higher value here means your CPU is spending too much time handling IO operations. Try improving IO performance or reducing IO at application level. More details about IOwait

Check CPU usage in Linux – hi si st

  • hi/si: Time spent in hardware interrupts or software interrupts.
  • st: Stolen CPU cycles. The hypervisor assigned these CPU cycles to another virtual machine. If you see a higher number in this field, try reducing the number of virtual machines from the host.

In general, we need to check which column plays a big part in CPU usage.

Troubleshoot high CPU usage in Linux

  • The user CPU and Nice CPU are high, indicating that the user mode process occupies more CPU, so you should focus on the performance of the process.
  • If the system CPU is high, it means that the kernel mode occupies more CPU, so you should focus on checking the performance of kernel threads or system calls.
  • I/O waiting for the CPU is high, indicating that the waiting time for I/O is relatively long, so you should focus on checking whether there is an I/O problem in the system storage.
  • Soft interrupt and hard interrupt are high, indicating that the processing program of soft interrupt or hard interrupt occupies more CPU, so you should focus on checking the interrupt service program in the kernel

Related Post:

Troubleshoot high iowait issue on Linux

Linux Performance: CPU Load Average

Share on facebook
Share on twitter
Share on linkedin
Liquid Web Managed Word Press