Detailed 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
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
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
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 |
|
相关推荐:
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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

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)

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.

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.

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.

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.

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.

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
