Linux TOP Command Parsing

Source: Internet
Author: User
Tags superuser permission

Comments: 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.

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.

Top-12:38:33 up 50 days, 7 users, load average: 60.58, 61.14, 61.22

Task: 203 total, 60 running, 139 sleeping, 4 stopped, 0 zombie

Cpu (s): 27.0% us, 73.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st

Mem: 1939780 k total, 1375280 k used, 564500 k free, 109680 k buffers

Swap: 4401800 k total, 497456 k used, 3904344 k free, 848712 k cached

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

4338 oracle 25 0 627 m 209 m 207 m R 0 11.0 297: 14.76 oracle

4267 oracle 25 0 626 m 144 m 143 m R 6 7.6 89: 16.62 oracle

3458 oracle 25 0 672 m 133 m 124 m R 0 7.1 1283: 08 oracle

3478 oracle 25 0 672 m 124 m 115 m R 0 6.6 1272: 30 oracle

3395 oracle 25 0 672 m 122 m 113 m R 0 6.5 1270: 03 oracle

3480 oracle 25 0 672 m 122 m 109 m R 8 6.4 1274: 13 oracle

3399 oracle 25 0 672 m 121 m 110 m R 0 6.4 1279: 37 oracle

4261 oracle 25 0 634 m 100 m 99 m R 0 5.3 86: 13.90 oracle

25737 oracle 25 0 632 m 81 m 74 m R 0 4.3 272: 35.42 oracle

7072 oracle 25 0 626 m 72 m 71 m R 0 3.8. 68 oracle

16073 Oracle 25 0 630 m 68 M 63 m r 8 3.6 175: 20.36 Oracle

16140 Oracle 25 0 630 m 66 m 60 M r 0 3.5 175: 13.42 Oracle

16122 Oracle 25 0 630 m 66 m 60 M r 0 3.5 176: 47.73 Oracle

786 Oracle 25 0 627 M 63 M 63 M r 0 3.4. 93 Oracle

4271 Oracle 25 0 627 M 59 m 58 m r 8 3.1 86: 09.64 Oracle

4273 Oracle 25 0 627 m 57 m 56 m R 8 3.0 84: 38.20 Oracle

22670 Oracle 25 0 626 m 50 M 49 M r 0 2.7 84: 55.82 Oracle

I. Top five rows of statistics

The first five lines in the statistical information area are the overall statistical information of the system.

1. The first line is the task queue information.

Same as the execution result of the uptime command:

[Root @ localhost ~] # Uptime

13:22:30 up 8 min, 4 users, load average: 0.14, 0.38, 0.25

The content is as follows:


Current Time

Up 50 days

System running time, in the format of minutes

1 user

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.

2. Information of the second and third behavior processes and CPU

When multiple CPUs exist, the content may exceed two rows. The content is as follows:

Tasks: 29 total

Process count

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 percentage of user space

1.0% sy

CPU usage of kernel space

0.0% ni

CPU usage percentage of processes that have changed their priorities in the process space

98.7% id

Idle CPU percentage

0.0% wa

Percentage of CPU time waiting for Input and Output

0.0% hi

0.0% si

3. The memory information of the behavior in the 4th and 5th sections.

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 kernel Cache

Swap: 192772 k total

Total number of swap Areas

0 k used

Total number of swap zones used

192772 k free

Total number of idle 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.The content already exists in the memory.The size of the swap area. When the corresponding memory is swapped out again, you do not have to write data to the swap zone.

Ii. Process Information

Column name



Process id


Parent process id


Real user name


User ID of the process owner


User Name of the process owner


Group Name of the process owner


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




Nice value. A negative value indicates a high priority, and a positive value indicates a low priority.


The last CPU used is only meaningful in multiple CPU environments.


CPU usage from the last update to the present


Total CPU time used by the process, in seconds


Total CPU time used by the process, in 1/100 seconds


Percentage of physical memory used by the Process


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


In the virtual memory used by the process, the swap size, in kb.


Physical memory used by the process, not swapped out, in kb. RES = CODE + DATA


Physical memory occupied by executable code, in kb


Physical memory occupied by parts other than executable code (Data Segment + stack), in kb


Size of shared memory, in kb


Page error count


The number of pages that have been modified since the last write to the present.


Process status.
D = uninterrupted sleep
R = run
S = sleep
T = tracking/stopping
Z = zombie Process


Command name/command line


If the process is sleeping, the system function name displayed in sleep


Task flag, refer to sched. h

The man command of top is explained as follows:

Listed below are top's available fields. They are always associated
With the letter shown, regardless of the position you may have
Established for them with the 'O' (Order fields) interactive command. Any
Field is selectable as the sort field, and you control whether they
Are sorted high-to-low or low-to-high. For additional information on
Sort provisions see topic 3c. TASK Area Commands.

A: PID-Process Id

The task's unique process ID, which periodically wraps, though never restarting at zero.

B: PPID-Parent Process Pid

The process ID of a task's parent.

C: RUSER-Real User Name

The real user name of the task's owner.

D: UID-User Id

The specified tive user ID of the task's owner.

E: USER-User Name

The specified tive user name of the task's owner.

F: GROUP-Group Name

The specified tive group name of the task's owner.

G: TTY-Controlling Tty

The name of the controlling terminal. This is usually the device
(Serial port, pty, etc.) from which the process was started, and which
It uses for input oroutput. However, a task need not be associated with
Terminal, in which case you'll see '? 'Displayed.

H: Pr-priority

The priority of the task.

I: Ni-Nice Value

The nice value of
Task. A negative nice value means higher priority, whereas a positive
Nice value means lower priority. Zero in this field simply means
Priority will not be adjusted in determining a task's dispatchability.

J: p-last used CPU (SMP)

A number representing the last used processor. In a true
SMP environment this will likely change frequently since the kernel
Intentionally uses weak affinity. Also, the very act of running top may
Break this weak affinity and cause more processes to change CPUs more
Often (because of the extra demand for cpu time ).

K: % CPU-CPU usage

The task's share of the elapsed CPU time since the last screen
Update, expressed as a percentage of total CPU time. In a true SMP
Environment, if 'irix mode' is Off, top will operate in 'solaris Mode'
Where a task's cpu usage will be divided
By the total number of CPUs. You toggle 'irix/Solaris 'modes with
'I' interactive command.


Total CPU time the task has used since it
Started. When 'cumulative mode' is On, each process is listed with
Cpu time that it and its dead children has used. You toggle 'cumulative
Mode 'with s', which is a command-line option and an interactive
Command. See the's 'interactive command for additional information
Regarding this mode.

M: TIME +-CPU Time, hundredths

The same as 'time', but reflecting more granularity through hundredths of a sec ond.

N: % MEM-Memory usage (RES)

A task's currently used share of available physical memory.

O: VIRT-Virtual Image (kb)

The total amount of virtual memory used by the task. It has des all
Code, data and shared libraries plus pages that
Have been swapped out. (Note: you can define the STATSIZE = 1 environment
Variable and the VIRT will be calculated from the/proc/#/state VmSize
Field .)


P: SWAP-Swapped size (kb)

The swapped out portion of a task's total virtual memory image.

Q: RES-Resident size (kb)

The non-swapped physical memory a task has used.


R: CODE-Code size (kb)

The amount of physical memory has Ted to executable code, also known as the 'text resident set 'size or TRS.

S: DATA-Data + Stack size (kb)

The amount of physical memory was Ted to other than executable code, also known the 'data resident set' size or DRS.

T: SHR-Shared Mem size (kb)

The amount of shared memory used by a task. It simply reflects memory that cocould be potentially shared with other processes.

U: nFLT-Page Fault count

The number of major page faults that have occurred for a task. A page
Fault occurs when a process attempts to read from or write to a virtual
Page that is not currently present in its address space. A major page
Fault is when disk access is involved in making that page available.

V: mcm t-Dirty Pages count

The number of pages that have been modified
Since they were last written to disk. Dirty pages must be written
Disk before the corresponding physical memory location can be used
Some other virtual page.

W: S-Process Status

The status of the task which can be one:

'D' = uninterruptible sleep

'R' = running

'S '= sleeping

'T' = traced or stopped

'Z' = zombie

Tasks shown as running shoshould be more properly thought of as 'ready
To run'-their task_struct is simply represented on the Linux
Run-queue. Even without a true SMP machine, you may see numerous tasks
In this state depending on top's delay interval and nice value.

X: Command-Command line or Program name

Display the command line used to start a task or the name of
Associated program. You toggle between command line and name with 'C ',
Which is both a command-line option and an interactive command.
When you 've chosen to display command lines, processes without a command
Line (like kernel threads) will be shown with only the program
Name in parentheses, as in this example: (mdrecoveryd)
Either form of display is subject to potential truncation if it's too
Long to fit in this
Field's current width. That width depends upon other fields selected,
Their order and the current screen width.

Note: The 'command' field/column is unique, in that it is not
Fixed-width. When displayed, this column will be allocated all remaining
Screen width (up to the maximum 512 characters) to provide for
Potential growth of program names into command lines.

Y: wchan-sleeping in Function

Depending on the availability of the kernel Link Map ('System. map '),
This field will show the name or the address of the kernel function in
Which the task is currently sleeping. Running tasks will display a dash
('-') In this column.

Note: By displaying this field, top's own working set will be
Increased by over 700Kb. Your only means of grouping that overhead will
Be to stop and restart top.

Z: Flags-Task Flags

This column represents the task's current scheduling flags
Which are expressed in hexadecimal notation and with zeros
Suppressed. These flags are officially specified ented in
<Linux/sched. h>. Less formal documentation can also be found on
The 'fields select' and 'order fields' screens.

By default, only important PID, USER, PR, NI, VIRT, RES, SHR, S, % CPU, % MEM, TIME +, and COMMAND columns are displayed.

2.1 use the shortcut key to change the display content.
(1) You can use the f key to change the display content.

Press f to display the column list. Press a-z to display or hide the corresponding column, and press enter to confirm.

(2) 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.

After setting, press enter to return to the interface.

Iii. command usage

For more information, see the MAN help document. Some content is listed here:

Command Format:

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

Parameter description:

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

P: only the status of a process is monitored 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: run the top Command in safe mode. This removes the potential danger of interactive commands.

I: no idle or dead processes are displayed on top.

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

In the top command display window, you can enter the following letters for interaction:

The help documentation is as follows:

Help for interactive commands-procps version 3.2.7

Window 1: Def: cumulative Mode Off. System: delay4.0 secs; Secure Mode Off.

Z, B global: 'Z' change color mappings; 'B' disable/enable bold

L, T, M toggle summaries: 'l' load AVG; 't'task/CPU stats; 'M' mem info

1, I toggle SMP view: '1' single/separate states; 'I 'irix/Solaris Mode

F, O. fields/columns: 'F' add or remove; 'O' change display order

F or O. Select sort Field

<,>. Move sort field: '<'Next Col left;'> 'Next Col right

R, H. Toggle: 'R' normal/reverse sort; 'H' show threads

C, I, S. Toggle: 'C' cmd name/line; 'I 'idle tasks;'s 'cumulative time

X, Y. Toggle highlights: 'X' sort field; 'y' running tasks

Z, B. Toggle: 'Z' color/MONO; 'B' bold/reverse (only if 'X' or 'y ')

U. show specific user only

N or #. set maximum tasks displayed

K, r manipulate tasks: 'K' kill; 'R' renice

D or s Set Update Interval

W write configuration file

Q quit

(Commands shown with '.' require a visible task display window)

Press 'H' or '? 'For help with windows,

H or? : 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.

Q: exit the program.

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: switch to the accumulative mode.

S: 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 ms. 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: Change the display project order.

L: the average load and startup time are displayed during switchover. Displays the first line of the shadow.

M: Switch to Display memory information. Displays the shadow memory rows.

T: process and CPU status information is displayed during switchover. Displays CPU lines in shadow.

C: Switch the display command name and the complete command line. The complete command is displayed. This function is useful.

M: sort by resident memory size.

P: sort by CPU usage percentage.

T: sort by time/accumulative time.

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

Related Article

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: 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.