Linux top commands

Source: Internet
Author: User
Tags superuser permission

Linux top commands
Linux top commands

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. Top is a dynamic display process. You can press the buttons to refresh the current status. if you execute this command on the foreground, it excludes the foreground until the user terminates the program. more accurately, the top command provides real-time monitoring of the status of the system processor. it displays the list of CPU-sensitive tasks in the system. this command can be used by CPU. the memory usage and execution time are used to sort tasks. Many features of this command can be set through interactive commands or in a custom file.

The following describes how to use it.

Top-22:32:05 up, 2 users, load average: 0.00, 0.00, 0.00

Tasks: 86 total, 1 running, 85 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: 1030680 k total, 432156 k used, 598524 k free, 58000 k buffers

Swap: 2129904 k total, 0 k used, 2129904 k free, 281932 k cached

Pid user pr ni virt res shr s % CPU % mem time + COMMAND

1 root 20 0 2900 1496 S 1264 0.0. 37 init

2 root 20 0 0 0 S 0.0 0.0. 01 kthreadd

3 root RT 0 0 0 S 0.0 0.0. 00 migration/0

4 root 20 0 0 0 S 0.0 0.0. 41 ksoftirqd/0

5 root RT 0 0 0 S 0.0 0.0. 00 migration/0

6 root RT 0 0 0 S 0.0 0.0. 36 watchdog/0

7 root 20 0 0 0 S 0.0 0.0. 21 events/0

8 root 20 0 0 0 S 0.0 0.0. 00 cgroup

9 root 20 0 0 0 S 0.0 0.0. 00 khelper

10 root 20 0 0 0 S 0.0 0.0. 00 netns

11 root 20 0 0 0 S 0.0 0.0. 00 async/mgr

12 root 20 0 0 0 S 0.0 0.0. 00 pm

13 root 20 0 0 0 S 0.0 0.0. 18 sync_supers

14 root 20 0 0 0 S 0.0 0.0. 13 bdi-default

15 root 20 0 0 0 S 0.0 0.0. 00 kintegrityd/0

Statistical information area

The first five lines are the overall statistics of the system.

The first line is the task queue information, which is the same as the execution result of the uptime command. The content is as follows:

22:33:35 # current time

Up # system running time, in the format of [hour: minute]

2 users # current Login User count

Load average: 0.06, 0.60, 0.48 # system load, that is, the average length of the task queue. The three values are the average values from 1 minute, 5 minutes, and 15 minutes ago to the present.

Second and Third, information about the process and CPU. When multiple CPUs exist, the content may exceed two rows. The content is as follows:

Tasks: 29 total # total Processes

1 running # Number of running Processes

28 sleeping # Number of sleep Processes

0 stopped # Number of stopped Processes

0 zombie # Number of zombie Processes

Cpu (s ):

0.3% us # CPU usage of user space

1.0% sy # CPU usage in kernel space

0.0% ni # Percentage of CPU used by processes whose priorities have changed in process space

98.7% id # Percentage of idle CPU

0.0% wa # Percentage of CPU time waiting for Input and Output

0.0% hi

0.0% si

Memory information of the last two behaviors. The content is as follows:

Mem:

191272 k total # total physical memory

173656 k used # total physical memory used

17616 k free # Total idle memory

22052 k buffers # Memory Used as the kernel Cache

Swap:

192772 k total # total number of swap Areas

0 k used # The total number of swap areas used

192772 k free # Total number of free swap Areas

123988 k cached # The total number of buffer swap Areas

The content in the memory is swapped out to the swap zone and then into the memory, but the used swap zone has not been overwritten. This value is the size of the SWAp zone where the content already exists. When the corresponding memory is swapped out again, you do not have to write data to the swap zone.

Process Information area

The details of each process are displayed at the bottom of the statistics area. First, let's take a look at the meaning of each column.

No.-column name-meaning

A PID process id

B PPID parent process id

C RUSER Real user name

D UID: User ID of the process owner

E USER: USER Name of the process owner

GROUP name of the owner of the f GROUP process

The terminal name of the g TTY startup process. Processes not started from the terminal are displayed

H PR priority

I NI nice value. A negative value indicates a high priority, and a positive value indicates a low priority.

The final CPU used by j P is only meaningful in multiple CPU Environments

K % percentage of CPU time used since the last CPU update to the present

L total cpu time used by the TIME process, in seconds

M TIME + the total cpu time used by the process, in the unit of 1/100 seconds

N % MEM percentage of physical memory used by the Process

O total virtual memory used by the VIRT process, in kb. VIRT = SWAP + RES

The SWAP size in the virtual memory used by the p SWAP process, in kb.

The size of the physical memory used by the q RES process, Not swapped out, in kb. RES = CODE + DATA

The physical memory occupied by the r CODE executable CODE, in kb.

Physical memory occupied by other parts (DATA Segment + stack) except the executable code of s DATA, in kb

T SHR shared memory size, in kb

U nFLT page error count

The number of modified pages that the last write to the present by v.

W S Process status.

D = uninterrupted sleep

R = run

S = sleep

T = tracking/stopping

Z = zombie Process

X COMMAND name/COMMAND line

Y WCHAN: if the process is sleep, the system function name in sleep is displayed.

Z Flags task flag, refer to sched. h

By default, only important PID, USER, PR, NI, VIRT, RES, SHR, S, % CPU, % MEM, TIME +, and COMMAND columns are displayed. You can use the shortcut keys below to change the display content.

Change display content

You can use the f key to select the displayed content. Press f to display the column list. Press a-z to display or hide the corresponding column, and press enter to confirm.

Press the o key to change the Column Display sequence. A lower-case a-z can move the corresponding column to the right, while an upper-case A-Z can move the corresponding column to the left. Press enter.

Press the F or O key in upper case, and then press a-z to sort the process according to the corresponding column. The uppercase R key can reverse the current sorting.

Command usage

1. Use format

Top [-] [d] [p] [q] [C] [S] [s] [n]

2. parameter description

D. Specify the interval between two screen information refreshes. Of course, you can use the s interactive command to change it.

P only monitors the status of a process by specifying the monitoring process ID.

Q This option will refresh top without any delay. If the caller has the superuser permission, top runs with the highest possible priority.

S indicates the accumulative mode.

S enables the top command to run in safe mode. This removes the potential danger of interactive commands.

I so that top does not show any idle or dead processes.

C. display the entire command line, not just the command name.

Internal commands

Interactive commands that can be used during top command execution. From the perspective of usage, mastering these commands is more important than mastering the options. These commands are single-letter. If the s option is used in the command line option, some of these commands may be blocked.

H shows 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.

Q: exit the program.

R reschedules 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 switches to the accumulative mode.

S changes 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 or F: add or delete a project from the current display.

O or O changes the order of projects displayed.

L switching displays average load and startup time information.

The m switch displays the memory information.

T Switch displays the process and CPU status information.

C switch to display the command name and complete command line.

M is sorted Based on the resident memory size.

P is sorted by CPU usage percentage.

T is sorted by time/accumulative time.

W write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

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.