search
HomeWeb Front-endJS TutorialDetailed explanation of top command and output results under Linux

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

$ 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

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 / ? 可显示帮助界面,原始为英文版,简单翻译如下:

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:列排序控制,按字母进行调整
 F or O . Select sort field 选择排序列
    . Move sort field: '' 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进行删除
 n or # . Set maximum tasks displayed 设置进程最大显示条数

 k,r    Manipulate tasks: 'k' kill; 'r' renice
      k:终止一个进程;r:重新设置一个进程的优先级别
 d 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 )
      注意:带.的命令需要一个可见的任务显示窗口

相关推荐:

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
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
JavaScript Engines: Comparing ImplementationsJavaScript Engines: Comparing ImplementationsApr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Beyond the Browser: JavaScript in the Real WorldBeyond the Browser: JavaScript in the Real WorldApr 12, 2025 am 12:06 AM

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Building a Multi-Tenant SaaS Application with Next.js (Backend Integration)Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration)Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript: Exploring the Versatility of a Web LanguageJavaScript: Exploring the Versatility of a Web LanguageApr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The Evolution of JavaScript: Current Trends and Future ProspectsThe Evolution of JavaScript: Current Trends and Future ProspectsApr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

Demystifying JavaScript: What It Does and Why It MattersDemystifying JavaScript: What It Does and Why It MattersApr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Is Python or JavaScript better?Is Python or JavaScript better?Apr 06, 2025 am 12:14 AM

Python is more suitable for data science and machine learning, while JavaScript is more suitable for front-end and full-stack development. 1. Python is known for its concise syntax and rich library ecosystem, and is suitable for data analysis and web development. 2. JavaScript is the core of front-end development. Node.js supports server-side programming and is suitable for full-stack development.

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

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