Linux TOP command usage

Source: Internet
Author: User

From: http://www.linuxsense.org/archives/53.html
Http://www.zxbc.cn/html/20080926/66161.html

Top

The top command is a common performance analysis tool in Linux. It can display the resource usage of various processes in the system in real time, similar to the Windows Task Manager. This topic describes how to use the top command.

Syntax:
Top [-] [d delay] [Q] [C] [s] [s] [I] [N]

Parameters
D: Specify the update interval, in seconds.
Q: there are no delayed updates. If a Super User exists, the top command is executed in the highest priority order.
C: displays the complete process path and name.
S: The accumulation mode, which accumulates the CPU time of the completed or disappearing sub-itinerary.
S: security mode.
I: no idle (idle) or useless (zombie) itinerary is displayed.
N: displays the number of updates. After the update is completed, the system will exit the top.

The top command is a major command for Linux system management. It can obtain a lot of information. Here we will describe the information it provides.

Top-11:18:25 up 47 days, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 83 total, 1 running, 82 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.0% St
Mem: 4052588 k total, 1220232 K used, 2832356 K free, 170300 K Buffers
Swap: 4192956 k total, 4 K used, 4192952 K free, 842676 K cached

PID user PR Ni virt res shr s % CPU % mem time + command
3591 root 15 0 12604 1048 R 808 0.3. 01 top
1 root 15 0 10344 680 s 568 0.0. 33 init
2 root RT-5 0 0 s 0.0 0.0. 24 migration/0
3 root 34 19 0 0 0 s 0.0 0: 01. 34 ksoftirqd/0
4 root RT-5 0 0 s 0.0 0.0. 00 watchdog/0
5 root RT-5 0 0 s 0.0 0.0. 00 migration/1
6 root 34 19 0 0 s 0.0 0.0. 00 ksoftirqd/1
7 root RT-5 0 0 s 0.0 0.0. 00 watchdog/1
8 root 10-5 0 0 s 0.0 0.0. 07 events/0
9 root 10-5 0 0 s 0.0 0.0. 07 events/1
10 root 10-5 0 0 s 0.0 0.0. 00 khelper

The items in the first line are the current time, system startup time, number of users logged on to the current system, and average load.
The second line shows all started processes, currently running, suspended and useless processes.
The third line shows the current CPU usage, including the proportion occupied by the system, user usage, and idle ratio.
The fourth line shows the usage of physical memory, including the total available memory, used memory, idle memory, and memory occupied by the buffer.
The fifth line shows the swap partition usage, including the total swap partition, used, idle, and cache size. The sixth line displays the largest number of items. The detailed explanations are listed below.

PID (process ID): process ID.
User: the user name of the process owner.
PR: process priority.
Ni: the priority value of the process.
Virt: Virtual Memory occupied by the process.
Res: The physical memory occupied by the process.
SHR: the shared memory value used by the process.
S: Process status. s indicates sleep, r indicates running, Z indicates frozen, and N indicates that the priority of the process is negative.
% CPU: CPU usage occupied by the process.
% Mem: Percentage of physical memory and total memory occupied by the process.
Time +: The total CPU time occupied by the process after it is started.
Command: the name of the startup command that the process starts. If this line does not appear, the process has a complete command line.

Some interactive commands can be used to complete other parameter functions during the use of the top command. These commands are started by using the shortcut key.
<Space>: refresh immediately.
CTRL + L: erase and override the screen.
H /? : Displays the help screen and provides some brief command summary.
K: terminate a process. The system prompts the user to enter the PID of the process to be terminated and the signal to be sent to the process. Generally, 15 signals can be used to terminate a process. If the process cannot end normally, use signal 9 to forcibly end the process. The default value is signal 15. This command is blocked in security mode.
I: Ignore idle and dead processes. This is a switch-on command.
R: reschedule the priority of a process. The system prompts the user to enter the process PID to be changed and the process priority value to be set. Entering a positive value will lower the priority, and vice versa will give the process a higher priority. The default value is 10.
S/D: Change the delay time between two refreshes. The system prompts the user to enter a new time in seconds. If there is a decimal number, it is converted to m s. If the input value is 0, the system will be refreshed continuously. The default value is 5 s. It should be noted that if the setting is too small, it is likely to cause constant refresh, so it is too late to see the display, and the system load will increase significantly.
F/F: add or delete a project from the current display.
O/o: Change the display project order.
N: set the maximum number of processes currently displayed.
L: the average load and startup time are displayed during switchover.
T: process and CPU status information is displayed during switchover.
M: Switch to Display memory information.
C: Switch the display command name and the complete command line.
Q: exit the TOP command.
P: sort by CPU usage.
T: sort by time and accumulated time.
M: sort by memory size.
S: switch to the accumulative mode.
W: Write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

 

As you can see, the top command is a powerful tool for monitoring the system, especially for system administrators. However, it consumes a lot of system resources.

You can also use the top command to monitor the process of a specified user. By default, the process of all users is monitored. If you want to view the situation of a specified user, press the "U" key in the terminal and enter the user name, the system will switch to the process running interface of the specified user.

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.