Skip to main content

top

top

概述

top是Linux系统中的一个互动的进程查看器,是一个文本模式的应用程序。它可让用户进行交互式操作,可横向或纵向滚动浏览进程列表,可通过方向键控制视图移动。

命令介绍

在终端界面,通过root用户执行dnf install procps-ng procps-ng-help(仅e版中存在procps-ng-help)命令安装procps-ng和procps-ng-help软件包。完成后,执行man 1 top命令,可查看其他更多参数及其含义。

TOP(1) User Commands TOP(1) NAME top-display Linux processes SYNOPSIS top-hv|-bcEHi0Ssl-d secs -n max -ulu user-ppid-ofld -w [cols] The traditional switches'-'and whitespace are optional DESCRIPTION The top program provides a dynamic real-time view of a running system.It can display system summary information as well as alist of processes or threads currently being managed by the Linux kernel.Thetypes of system summary information shown and the types,order and size of information displayed for processes are all user configurable and that configura tion can be made persistent across restarts. he program provides a limitedinteractive interface for process manpulation as well as a much more extensive interface for personal configurationencompassing every aspect of its operation.And while top is referred to throughout this document,you are free to name the program anything you wish. That new name,possibly an alias,will then be reflected on top's display and used when reading and writing a configuration file. OVERVIEW Documentation The remaining Table of Contents OVERVIEW Operation Linux Memory Types 1.COMMAND-LINE Options 2.SUMMARY Display a.UPTIME and LOAD Averages b. TASK and CPU States C.MEMORY Usage 3.FIELDS/Columns Display a.DESCRIPTIONS of Fields b.MANAGING Fields 4.INTERACTIVE Commands a.GLOBAL Commands b. SUMMARY AREA Commands C. TASK AREA Commands 1.Appearance 2. Content 3.Size 4.Sorting d.COLOR Mapping 5.ALTERNATE-DISPLAY Provisions


交互式命令如下:

4.INTERACTIVE Commands Listed below is a brief index of commands within categories.Some commands appear more than once their meaning or scope may vary depending on the context in which they are issued. 4a.GLobal-Commands <Ent/Sp>?,=,0, A,B,d,E,e,g,h,H,I,k,q,r,s,W,x,Y,z 4b.Summary-Area-Commands c,t,t,m,1,2,3 4c.Task-Area-Commands Appearance:b,J,j,x,y,Z c,f,F,o,o,s,u,U,V,v Content: Size: #,i,n Sorting: <,>,f,F,R 4d. Color- Mapping <Ret>,a,B,b,H,M,q,S,T,w,z,0-7 5b.Commands - for-Windows ,二,+,A,a,g,G,w 5c.ScrolTing-a-Window C,Up,Dn,Left,Right,PgUp,PgDn,Home,End 5d.Searching-in-a-Window L,&


### 功能测试

以root用户身份登录系统,在终端界面,执行top命令,显示进程的实时状态。

■按下z键,输出上色;再次按下z键,退出上色。

■按下N键,以PID的大小的顺序排列表示进程列表。

■按下P键,以CPU占用率大小的顺序排列进程列表。

■按下m键,以内存占用率大小的顺序排列进程列表。

■按下f键,选择默认显示的列。

■示例如下:

◆显示内存情况。

top-17:58:40up1:28,4users, load average:0.00,0.01,0.00 Tasks:159 total, 1running,155sleeping, 3 stopped, 0zombie 0.1sy, 0.0ni,99.9 id, 0.wa, %Cpu(s):0.0us, Gohi,oosi,oost MiB Mem : 6814.1 total, 4905.1 free, 935.1 used, 974.0 buff/cache MiB Swap: 3071.9 total, 3071.9 free, 0.0used. 5516.1avail Mem PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND 2047 lightdm 20 01203328 203520 0.0 66880S 2.9 0:09.83 lightdm-deepin- 2111 lightdm 20 0 893184 102208 55808 S 0.0 1.5 0:00.56 onboard 1534 root 473472 56960 20 0 34368 S 0.0 0.8 0:01.09Xorg 545 root 20 0 94976 46208 39872 0.0 0.7 S 0:00.52systemd-journal 3554 root 20 0 334656 44480 16064 S 0.0 0.6 0:00.56 firewalld 547904 1457 root 20 0 35456 14272 S 0.0 0.5 0:00.41 Lvmdbusd 1483 root 20 0 472768 33920 13504 S 0.0 0.5 0:00.49tuned 1311 root 20 0 695360 30464 17920 S 0.0 0.4 0:00.13 NetworkManager 2060root 1313152 28928 20 0 13760 S 0.0 0.4 0:00.18 dde-system-daem 1324 root 20 0 222400 27712 21248 S 0.0 0.4 0:01.25 rsyslogd 734976 27328 0.0 2091 root 20 0 12736 S 0.4 0:00.08 dde-authority 1495 polkitd 20 0 1660864 26048 14976 0.0 S 0.4 0:00.21 polkitd 1329 root 20 0 403776 23552 11392 S 0.0 0.3 0:00.08 udisksd 0 177728 20480 1 root 20 9024 S 0.0 0.3 0:01.82systemd 2046 Lightdm 20 0 502464 19392 8448 S 0.0 0.3 0:00.01 greeter-display 4257 root 20 0 23680 17856 9536 S 0.0 0.3 0:00.06sshd 0 23680 17792 9472 0.0 4261 root 20 S 0.3 0:00.05 sshd 23488 2163 root 20 0 17664 9472 S 0.0 0.3 0:00.06 sshd 2167 root 20 0 23488 17664 9408 S 0.0 0.3 0:00.06sshd 2473 root 0 23168 16768 8640 0.0 0:00.05sshd 20 S 0.2 2667 root 20 0 23168 16768 8640 S 0.0 0.2 0:00.04sshd 577 root 20 0 36416 16384 7680 S 0.0 0.2 0:00.43 systemd-udevd 2100root 20 0 25024 15936 7680 S 0.0 0.2 0:00.00 lightdm 14848 2172 root 20 0 24576 8448 S 0.0 0.2 0:00.09 systemd 24512 14784 8448 2032 lightdm 20 0 S 0.0 0.2 0:00.12systemd 2341 20 0 24576 14784 8448 S 0.0 0.2 0:00.10 systemd testuse+ 2480 testl 20 0 24576 14784 8448 S 0.0 0.2 0:00.09 systemd 1336 root 20 0 24448 14720 7488 S 0.0 0.2 0:00.23 sys temd- Logind 2026root 20 0 170304 14656 8000 0.0 0.2 0:00.01 lightdm S 2482 testl 20 0 183104 14016 0 S 0.0 0.2 0:00.00(sd-pam) 13952 0.0 0.2 2343 testuse+ 20 0 183104 0 S 0:00.00(sd-pam) 2034 lightdm 20 0 117568 13824 0 S 0.0 0.2 0:00.00(sd-pam) 20 182656 13824 2174 root 0 0 S 0.0 0.2 0:00.00(sd-pam) 581 systemd+ 20 0 23104 12800 7296S 0.0 0.2 0:00.14 systemd-network


◆显示上色。

![](/img/docs/image172.png)

◆按照cpu使用大小排序。

1:31, 4 users, load average:0.00,0.00,0.00 top-18:02:07up 1 running,152sleeping 0zombie Tasks:156 total, 3 stopped, %Cpu(s):0.0us, 0.0sy, 0.0ni,100.0 id, 00wa,oohi,oosi,oost 6814.1 4904.7 free, 935.4 used, MiB Mem: total, 974.1 buff/cache MiB Swap: 3071.9 total, 3071.9 free, 0.0 used. 5515.8 avail Mem PID USER PR NI VIRT RES SHR S %CPU 8MEM TIME+ COMMAND 2047 lightdm 20 0 1203328 203520 66880S 0.4 2.9 0:10.17lightdm-deepin- 20 1 root 0 177728 20480 9024S 0.0 0.3 0:01.82 systemd 2 root 20 0 0 0S 0.0 0.0 0:00.00 kthreadd 0 3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00rcu_par_gp 0 0:00.00 kworker/0:0H-kblockd 6 root 0 -20 0 0 I 0.0 0.0 8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq 9 0 0.0 0.0 0:00.00 ksoftirqd/0 root 20 0 0 0 S 10 root 20 0 0 0 0 I 0.0 0.0 0:00.05 rcu sched 11 root 20 0 0 0.0 0.0 0 0 I 0:00.00 rcu_bh 12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 13 root 20 0 0 0 S 0.0 0.0 0:00.00cpuhp/0 0 20 0 14 root 0 0 0 S 0.0 0.0 0:00.00 cpuhp/1 15 root 0 0 0 0 S 0.0 0.0 0:00.00migration/1 rt 20 16 root 0 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/1 18 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/1:0H-kblockd 19 0 root 20 0 0 0 S 0.0 0.0 0:00.00 cpuhp/2 20 root rt 0 0 0 0 S 0.0 0.0 0:00.00migration/2 0 21 root 20 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/2 23 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/2:0H-kblockd 0 0.0 0.0 0:00.00 cpuhp/3 24 root 20 0 0 0 S 25 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/3 26 root 20 0 0 0.0 0 0 S 0.0 0:00.00 ksoftirqd/3 0 28 root 0 -20 0 0 I 0.0 0.0 0:00.00 kworker/3:0H-kblockd 29 root 20 0 0.0 0.0 0 0 0 S 0:00.00 kdevtmpfs 0 30 root 0 -20 0 0 I 0.0 0.0 0:00.00 netns 31 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd root 33 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd 34 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper 35 0 root 0 20 0 0 I 0.0 0.0 0:00.00 writeback 0000 36 root 20 0 0 0 S 0.0 0.0 0:00.00kcompactdo 37 root 25 5 0 0 S 0.0 0.0 0:00.00 ksmd 38 root 39 19 0 0 S 0.0 0.0 0:00.00 khugepaged 0 39 root 0 -20 0 I 0.0 0.0 0:00.00 crypto 40root 0-20 0 0 0 I 0.0 0.0 0:00.00 kintegrityd