Use the top command in CentOS to view a detailed illustration of the CPU


CentOS is the product of recompilation of RHEL (Red Hat Enterprise Linux) source code, and has corrected many known bugs on the basis of RHEL. Compared with other Linux distributions, its stability is reliable.

In the process of system maintenance, it may be necessary to check the CPU utilization at any time and analyze the system status according to the corresponding information. In CentOS, you can view CPU usage through the top command. After running the top command, the CPU usage status will be displayed in full screen mode and will be in dialogue mode – the display mode can be controlled with the top command. The command to exit top is Q (hit Q once during top operation).

Enter “top” in the command line to start top. After running, it is shown in the following figure:


As shown in the figure above, the full screen dialogue mode of top can be divided into three parts: system information bar, command input bar and process list bar.

  Part I – top system information bar

  First line (top)

“00:11:04” is the current time of the system;

“3:35” is the operation time from the start of the system to the present;

“2 users” refers to the users currently logged in to the system, more specifically, the number of terminals logged in to the user – the connection of the same user to multiple terminals of the system at the same time will be regarded as multiple users connected to the system, and the number of users here will also be expressed as the number of terminals;

“Load average” is the average value of the current system load. The following three values are the average number of processes 1 minute ago, 5 minutes ago and 15 minutes ago respectively. Generally, it can be considered that when this value exceeds the number of CPUs, the CPU will have a hard load on the processes contained in the current system;

  Second line (tasks)

“59 total” is the total number of current system processes;

“1 running” is the number of processes currently running;

“58 sleeping” is the number of processes currently in the waiting state;

“0 stopped” is the number of stopped system processes;

“0 zombie” is the number of restored processes;

  Third line (CPUs)

Respectively represents the current utilization rate of CPU;

  Line 4 (MEM)

It represents the total amount of memory, current usage, free memory and memory in buffer use respectively;

  Line 5 (SWAP)

Indicates that the category is the same as the fourth line (MEM), but this reflects the use of swap. Generally, the frequent use of swap will be regarded as the result of insufficient physical memory.

  Part II – internal command prompt bar in the middle

During top operation, the display mode of the process can be controlled through the internal command of top. The internal commands are as follows:

S – change screen update frequency

L – turn off or on the representation of the top information in the first line of the first part

T – close or open the representation of tasks in the second line and CPUs in the third line of the first part

M – turn off or turn on the representation of MEM in the fourth line and swap in the fifth line of the first part

N – indicates the process list in the order of PID size

P – lists processes in order of CPU usage

M – arranges the process list in order of memory usage

H – display help

N – sets the number of processes displayed in the process list

Q – exit top

S – change the screen update cycle

  Part III – process list bar at the bottom

The process list distinguished by PID will be updated regularly according to the set screen update time. You can control the display here through the top internal command.

In general, we maintain the server through remote monitoring, so that the local terminal of the server can run top in real time, which is one of the fast and convenient ways to monitor the server status locally.