Home Web Front-end JS Tutorial Detailed explanation of top command and output results under Linux

Detailed explanation of top command and output results under Linux

Mar 05, 2018 am 09:38 AM
linux result output

The top command is a commonly used performance analysis tool under Linux. It can display the resource usage of each process in the system in real time. It is often used for server-side performance analysis. This article mainly explains the detailed explanation of the top command parameters and the explanation of the output results. I hope it can help everyone. .

top command description

1

2

3

4

5

6

7

8

9

10

11

12

13

$ top

top - 16:07:37 up 241 days, 20:11, 1 user, load average: 0.96, 1.13, 1.25

Tasks: 231 total,  1 running, 230 sleeping,  0 stopped,  0 zombie

Cpu(s): 12.7%us, 8.4%sy, 0.0%ni, 77.1%id, 0.0%wa, 0.0%hi, 1.8%si, 0.0%st

Mem: 12196436k total, 12056552k used,  139884k free,  64564k buffers

Swap: 2097144k total,  151016k used, 1946128k free, 3120236k cached

 

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

18411  pplive  20   0 11.9g  7.8g  5372  S 220.2  67.1   16761:00  java

 1875  pplive  20   0 3958m  127m  4564  S  4.6   1.1   12497:35  java

  4  root   20   0   0   0    0  S  0.3   0.0  184:01.76  ksoftirqd/0

  13  root   20   0   0   0    0  S  0.3   0.0  135:49.83  ksoftirqd/2

  25  root   20   0   0   0    0  S  0.3   0.0  136:54.49  ksoftirqd/5

Copy after login

The result of the top command is divided into two parts:

Statistical information: The first five lines are the statistical information of the overall system;
Process information: The table-like area below the statistical information displays the detailed information of each process, which is refreshed every 5 seconds by default.

Statistical information description:

Line 1: Top task queue information (system running status and average load), the same as the uptime command result.
Paragraph 1: The current system time, for example: 16:07:37
Paragraph 2: System running time, the time before restarting. The longer the time, the more stable the system will be.
Format: up xx days, HH:MM
For example: 241 days, 20:11, means it has been running continuously for 241 days, 20 hours and 11 minutes
Paragraph 3: The number of currently logged in users, for example: 1 user , indicating that there is currently only one user logged in
Paragraph 4: System load, that is, the average length of the task queue, the three values ​​​​respectively count the average system load in the last 1, 5, and 15 minutes

Average system load : In the case of a single-core CPU, 0.00 means no load, 1.00 means just full load, more than 1 side means overload, the ideal value is 0.7;
Multi-core CPU load: Number of CPU cores * ideal value 0.7 = ideal load, for example : The 4-core CPU load does not exceed 2.8, which means there is no high load.

Line 2: Tasks process related information
Paragraph 1: Total number of processes, for example: Tasks: 231 total, indicating a total of 231 processes running
Paragraph 2: Number of running processes, For example: 1 running,
Paragraph 3: Number of sleeping processes, for example: 230 sleeping,
Paragraph 4: Number of stopped processes, for example: 0 stopped,
Paragraph 5: Number of zombie processes, For example: 0 zombie

Line 3: Cpus CPU related information. If it is a multi-core CPU, press the number 1 to display the CPU information of each core. At this time, line 1 will be converted to the Cpu core number line, and the number 1 can be switched back and forth. .
Paragraph 1: us user space occupies the CPU percentage, for example: Cpu(s): 12.7%us,
Paragraph 2: sy kernel space occupies the CPU percentage, for example: 8.4%sy,
Paragraph 3 Section: ni The percentage of CPU occupied by processes that have changed priorities in the user process space, for example: 0.0% ni,
Section 4: id The percentage of idle CPU, for example: 77.1% id,
Section 5: wa Waiting The percentage of CPU time for input and output, for example: 0.0% wa,
Paragraph 6: hi The total time spent by the CPU serving hardware interrupts, for example: 0.0% hi,
Paragraph 7: si CPU serving soft interrupts The total time spent, for example: 1.8%si,
Paragraph 8: st Steal time The CPU time stolen by the virtual machine by the hypervisor (if the vm is currently under a hypervisor, the hypervisor actually also consumes part of the CPU processing Time)

Line 4: Mem memory related information (Mem: 12196436k total, 12056552k used, 139884k free, 64564k buffers)
Paragraph 1: Total physical memory, for example: Mem: 12196436k total ,
Paragraph 2: Total amount of physical memory used, for example: 12056552k used,
Paragraph 3: Total amount of free memory, for example: Mem: 139884k free,
Paragraph 4: Used as kernel cache The amount of memory, for example: 64564k buffers

Line 5: Swap swap partition related information (Swap: 2097144k total, 151016k used, 1946128k free, 3120236k cached)
Paragraph 1: Total swap area, For example: Swap: 2097144k total,
Paragraph 2: Total amount of swap area used, for example: 151016k used,
Paragraph 3: Total amount of free swap area, for example: 1946128k free,
Paragraph 4 : Total buffered swap area, 3120236k cached

Process information:
Press f in the top command to view the displayed column information, and press the corresponding letter to turn on/off the column. Capital letters indicate on. Lowercase letters indicate closed. The columns marked with * are the default columns.

A: PID = (Process Id) 进程Id;
E: USER = (User Name) 进程所有者的用户名;
H: PR = (Priority) 优先级
I: NI = (Nice value) nice值。负值表示高优先级,正值表示低优先级
O: VIRT = (Virtual Image (kb)) 进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES
Q: RES = (Resident size (kb)) 进程使用的、未被换出的物理内存大小,单位kb。RES=CODE+DATA
T: SHR = (Shared Mem size (kb)) 共享内存大小,单位kb
W: S = (Process Status) 进程状态。D=不可中断的睡眠状态,R=运行,S=睡眠,T=跟踪/停止,Z=僵尸进程
K: %CPU = (CPU usage) 上次更新到现在的CPU时间占用百分比
N: %MEM = (Memory usage (RES)) 进程使用的物理内存百分比
M: TIME+ = (CPU Time, hundredths) 进程使用的CPU时间总计,单位1/100秒
b: PPID = (Parent Process Pid) 父进程Id
c: RUSER = (Real user name)
d: UID = (User Id) 进程所有者的用户id
f: GROUP = (Group Name) 进程所有者的组名
g: TTY = (Controlling Tty) 启动进程的终端名。不是从终端启动的进程则显示为 ?
j: P = (Last used cpu (SMP)) 最后使用的CPU,仅在多CPU环境下有意义
p: SWAP = (Swapped size (kb)) 进程使用的虚拟内存中,被换出的大小,单位kb
l: TIME = (CPU Time) 进程使用的CPU时间总计,单位秒
r: CODE = (Code size (kb)) 可执行代码占用的物理内存大小,单位kb
s: DATA = (Data+Stack size (kb)) 可执行代码以外的部分(数据段+栈)占用的物理内存大小,单位kb
u: nFLT = (Page Fault count) 页面错误次数
v: nDRT = (Dirty Pages count) 最后一次写入到现在,被修改过的页面数
y: WCHAN = (Sleeping in Function) 若该进程在睡眠,则显示睡眠中的系统函数名
z: Flags = (Task Flags ) 任务标志,参考 sched.h
X: COMMAND = (Command name/line) 命令名/命令行

top命令选项

-b:以批处理模式操作;
-c:显示完整的治命令;
-d:屏幕刷新间隔时间;
-I:忽略失效过程;
-s:保密模式;
-S:累积模式;
-i<时间>:设置间隔时间;
-u<用户名>:指定用户名;
-p<进程号>:指定进程;
-n<次数>:循环显示的次数。

top命令交互

常用交互操作

基础操作

1:显示CPU详细信息,每核显示一行
d / s :修改刷新频率,单位为秒
h:可显示帮助界面
n:指定进程列表显示行数,默认为满屏行数
q:退出top

面板隐藏显示

l:隐藏/显示第1行负载信息;
t:隐藏/显示第2~3行CPU信息;
m:隐藏/显示第4~5行内存信息;

进程列表排序

M:根据驻留内存大小进行排序;
P:根据CPU使用百分比大小进行排序;
T:根据时间/累计时间进行排序;

详细交互指令:h / ? 可显示帮助界面,原始为英文版,简单翻译如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

Help for Interactive Commands - procps version 3.2.8

Window 1:Def: Cumulative mode Off. System: Delay 3.0 secs; Secure mode Off.

 

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

      Z:修改颜色配置;B:关闭/开启粗体

 l,t,m   Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info

      l:隐藏/显示第1行负载信息;t:隐藏/显示第2~3行CPU信息;m:隐藏/显示第4~5行内存信息;

 1,I    Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode

      1:单行/多行显示CPU信息;I:Irix/Solaris模式切换

 f,o   . Fields/Columns: 'f' add or remove; 'o' change display order

      f:列显示控制;o:列排序控制,按字母进行调整

 or O . Select sort field 选择排序列

 <,>   . Move sort field: '<&#39; next col left; &#39;>' next col right 上下移动内容

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

      R:内容排序;H:显示线程

 c,i,S  . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time

      c:COMMAND列命令名称与完整命令行路径切换;i:忽略闲置和僵死进程开关;S:累计模式切换

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

      x:列排序;y:运行任务

 z,b   . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')

      z:颜色模式;b:粗体开关 仅适用于x,y模式中

 u    . Show specific user only 按用户进行过滤,当输入错误可按Ctrl + Backspace进行删除

 or # . Set maximum tasks displayed 设置进程最大显示条数

 

 k,r    Manipulate tasks: 'k' kill; 'r' renice

      k:终止一个进程;r:重新设置一个进程的优先级别

 or s  Set update interval 改变两次刷新之间的延迟时间(单位为s),如果有小数,就换算成ms。输入0值则系统将不断刷新,默认值是5s;

 W     Write configuration file 将当前设置写入~/.toprc文件中

 q     Quit    退出

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

      注意:带.的命令需要一个可见的任务显示窗口

Copy after login

相关推荐:

linux命令:top命令

php如何执行top命令讲结果写入文件.txt

Linux下使用python调用top命令获得CPU利用率

The above is the detailed content of Detailed explanation of top command and output results under Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to view the docker process How to view the docker process Apr 15, 2025 am 11:48 AM

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

What is vscode What is vscode for? What is vscode What is vscode for? Apr 15, 2025 pm 06:45 PM

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages ​​and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages ​​and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

See all articles