The top command in Linux systems is described in detail

Source: Internet
Author: User
Tags sorts time interval

Some of the common operational commands in Linux are described later, using these commands to quickly locate the problem and solve the problem. Today,-top commands from the most common start.

Introduction to command meaning

After running the top command, the following will appear

Top-03:37:17 up min, 2 users, Load average:0.00, 0.00, 0.00
Tasks:10 Total, 1 running, 9 sleeping, 0 stopped, 0 zombie
%CPU (s): 0.0 us, 0.0 sy, 0.0 ni,100.0 ID, 0.0 wa, 0.0 hi, 0.0 si, 0.0th
KiB mem:151552 Total, 144720 used, 6832 free, 0 buffers
KiB swap:36864 Total, 1164 used, 35700 free, 125976 cached

PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND
1 Root 0 3016 1536 1288 S 0.0 1.0 0:00.07 Init
2 Root 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/5670
3 Root 0 0 0 0 S 0.0 0.0 0:00.00 khelper/5670
1602 Root 0 9140 2524 2408 S 0.0 1.7 0:00.10 sshd
1604 Root 0 3036 1464 1328 S 0.0 1.0 0:00.00 Bash
1621 Root 0 6340 732 628 S 0.0 0.5 0:00.00 sshd
24550 Root 0 4428 1520 1112 S 0.0 1.0 0:00.08 Ss-server
24576 Root 0 9144 2996 2396 S 0.0 2.0 0:00.02 sshd
24578 Root 0 3028 1640 1324 S 0.0 1.1 0:00.00 Bash
24582 Root 0 2904 1280 912 R 0.0 0.8 0:00.02 Top

1. System Statistic Information

The first five elements are the statistical information of the system as a whole. Where the first line is the task queue information, the execution result of the same uptime command. The meaning is as follows

03:37:17 Current Time
Up to min system running time
2 User Current Logged-in users
Load average:0.00, 0.00, 0.00 System Load, that is, the average length of the task queue. Three values are 1 minutes, 5 minutes, and 15 minutes ago to the current average.

The second to third behavior process and CPU information. When you have more than one CPU, the content can be more than two lines. The meaning is as follows:

Total Process Tasks:10
1 running number of processes running
9 sleeping the number of sleep processes
0 stopped number of processes stopped
0 Zombie Zombie Process number
CPU (s): 0.0% US user space uses CPU percent
0.0% sy kernel space occupies CPU percent
0.0% ni% of processes in user process space that have changed priority
100.0% ID Idle CPU percent
0.0% wa% CPU time waiting for input and output, related to IO performance
0.0% hi
0.0% si

The last two acts of memory information. The contents are as follows:


Total physical memory of KiB mem:151552
Total physical memory used by 144720 used
6832 free Memory Total
0 buffers as the kernel cache memory
Total Exchange area of KiB swap:36864
Total number of swap areas used by 1164 used
35700 free Idle swap area total
125976 cached the total number of swap areas buffered.
The content in memory is swapped out to the swap area and then swapped into memory, but the used swap area has not been overwritten,
The value is the size of the swap area where the content already exists in memory.
When the corresponding memory is swapped out again, you do not have to write to the swap area again.
2. Process information

In the process information, there are several columns

PID USER PR NI virt RES SHR S%cpu%mem time+ COMMAND

These parameters are explained in detail below


PID Process ID
Username of user Process Owner
PR Priority
NI nice value. A negative value indicates a high priority, and a positive value indicates a low priority
Total amount of virtual memory used by the virt process, in kilobytes. Virt=swap+res
The amount of physical memory used by the RES process that has not been swapped out, in kilobytes. Res=code+data
SHR shared memory size, per kb
S process status.
D= an uninterrupted sleep state
R= Run
S= Sleep
t= Tracking/Stopping
z= Zombie Process
%cpu percentage of CPU time that was last updated to current
Percentage of physical memory used by the%MEM process
Command name/command line
Introduction to command usage

The use format for the top command is

Top [-] [d] [P] [Q] [C] [C] [s] [s] [n]

The parameters are described below:


d Specifies the time interval between refresh of the screen information every two times. Of course, users can use the s interactive command to change it.
P monitors only the state of a process by specifying the monitoring process ID.
Q This option will cause top to be refreshed without any delay. If the calling program has Superuser privileges, top will run at the highest possible priority level.

S Specifies the cumulative mode
s makes the top command run in Safe mode. This removes the potential risk of interaction commands.
I make top do not show any idle or zombie processes.
C Displays the entire command line instead of just displaying the command name
The following are some of the interaction commands that you can use during the top command execution. From a usage point of view, mastering these commands is more important than mastering the options. These commands are all single letters, and if the S option is used in command-line options, some of these commands may be blocked.


Ctrl+l Erase and rewrite the screen.
H or? Displays the help screen, giving some brief summary instructions.
K Terminates a process. The user is prompted to enter the process PID that needs to be terminated, and what signal needs to be sent to the process.
The general termination process can use 15 signals, and if not, use signal 9 to force the end of the process. The default value is signal 15.
This command is blocked in safe mode.
I ignore idle and zombie processes. This is a switch command.
Q quit the program.
R to reschedule a process's priority level. The system prompts the user to enter the process PID to be changed and the process priority value that needs to be set.
Entering a positive value causes the priority to be lowered, whereas the process can have a higher priority. The default value is 10.
S switch to cumulative mode.
s changes the delay time between two times of refresh. The user will be prompted to enter a new time in the unit S. If there is a decimal number, it is converted to M S.
Enter a value of 0 and the system will refresh continuously with the default value of 5 S. It is important to note that if you set too small a time, it is likely to cause a constant refresh,
So it is too late to see the display, and the system load will be greatly increased.
F or F to add or remove items from the current display.
O or O change the order in which items are displayed.
L Toggle Display Average load and start time information.
M toggles the display of memory information.
T toggles the display of process and CPU state information.
C Toggles the display of the command name and the full command line.
M sorts based on the size of the resident memory.
P is sorted according to the percentage size used by the CPU.
T sorts according to time/cumulative time.
W writes the current settings to the ~/.TOPRC file. This is the recommended method for writing the top configuration file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.