Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the top command

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you how to use the top command. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Top command is a commonly used performance analysis tool under Linux, which can display the resource consumption of each process in the system in real time, similar to the task manager of Windows. How to use it is described in detail below.

Top-01:06:48 up 1:22, 1 user, load average: 0.06,0.60,0.48

Tasks: 29 total, 1 running, 28 sleeping, 0 stopped, 0 zombie

Cpu (s): 0.3% us, 1.0% sy, 0% ni, 98.7% id, 0% wa, 0% hi, 0% si

Mem: 191272k total, 173656k used, 17616k free, 22052k buffers

Swap: 192772k total, 0k used, 192772k free, 123988k cached

PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND

1379 root 16 0 7976 2456 1980 S 0.7 1.3 0:11.03 sshd

14704 root 16 0 2128 980 796 R 0.7 0.5 0:02.72 top

1 root 16 0 1992 632 544 S 0.0 0.3 0:00.90 init

2 root 34 19 00 0 S 0.0 0.00: 00.00 ksoftirqd/0

3 root RT 00 00 S 0.0 0.00: 00.00 watchdog/0

The first five lines in the statistics area are the statistics of the system as a whole. The first line is the task queue information, which is the same as the execution result of the uptime command. Its contents are as follows:

01:06:48

Current time

Up 1:22

System running time, format is hours: minutes

1 user

Number of currently logged in users

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, third behavior process and CPU information. When there is more than one CPU, these may be more than two lines. The contents are as follows:

Tasks: 29 total

Total number of processes

1 running

Number of processes running

28 sleeping

Number of sleep processes

0 stopped

Number of processes stopped

0 zombie

Number of zombie processes

Cpu (s): 0.3% us

Percentage of CPU occupied by user space

1.0% sy

Percentage of CPU occupied by kernel space

0.0% ni

Percentage of CPU occupied by processes that have changed priority in user 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

The last two behaviors are memory information. The contents are as follows:

Mem: 191272k total

Total physical memory

173656k used

Total amount of physical memory used

17616k free

Total free memory

22052k buffers

Amount of memory used as kernel cache

Swap: 192772k total

Total amount of exchange area

0k used

Total number of switching areas used

192772k free

Total free exchange area

123988k cached

The total number of buffered swap areas.

The contents of the memory are swapped out to the swap area, and then swapped into memory, but the used swap area has not been overwritten

This value is the size of the swap area in which these contents already exist in memory.

When the corresponding memory is swapped out again, there is no need to write to the swap area.

The details of each process are displayed at the bottom of the statistics area of the process information area. First of all, let's understand the meaning of each column.

Serial number

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

F

GROUP

The group name of the process owner

G

TTY

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

H

PR

Priority

I

NI

Nice value. Negative values indicate high priority, while positive values indicate low priority.

J

P

The final use of CPU makes sense only in a multi-CPU environment

K

% CPU

Percentage of CPU time spent since last update

L

TIME

Total CPU time used by the process, in second

M

TIME+

Total CPU time used by the process (in 100 seconds)

N

% MEM

Percentage of physical memory used by the process

O

VIRT

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

P

SWAP

The size swapped out in the virtual memory used by the process, in kb.

Q

RES

The amount of physical memory used by the process and not swapped out, in kb. RES=CODE+DATA

R

CODE

The amount of physical memory consumed by executable code, in kb

S

DATA

The amount of physical memory occupied by parts other than executable code (data segment + stack), in kb

T

SHR

Shared memory size (in kb)

U

NFLT

Number of page errors

V

NDRT

The number of pages that have been modified since it was last written.

W

S

Process status.

D = uninterruptible sleep state

R = run

S = sleep

T = track / stop

Z = zombie process

X

COMMAND

Command name / Command Line

Y

WCHAN

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

Z

Flags

Task flag, refer to sched.h

By default, only the more important PID, USER, PR, NI, VIRT, RES, SHR, S,% CPU,% MEM, TIME+, COMMAND columns are displayed. You can change the display through the keyboard shortcuts below.

. Change the content of the display. You can select what is displayed through the f key. Press the f key to display the list of columns, press amurz to show or hide the corresponding columns, and finally press enter to determine.

. Press o (lowercase) to change the order in which the columns are displayed. Press lowercase Amurz to move the corresponding column to the right, and uppercase Amurz to move the corresponding column to the left. Finally, press the enter key to confirm.

. Press the uppercase F or O (uppercase) key, and then press amurz to sort the processes by the corresponding columns. The uppercase R key reverses the current sort.

The above is the use of the top command shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report