50.第十一章 进程和计划任务(二)
作者:互联网
2.进程管理和性能相关工具
Linux系统状态的查看及管理工具:pstree, ps, pidof, pgrep, top, htop, glance, pmap, vmstat, dstat,kill, pkill, job, bg, fg, nohup
2.1 进程树 pstree
pstree 可以用来显示进程的父子关系,以树形结构显示
格式:
pstree [OPTION] [ PID | USER ]
常用选项:
-p 显示PID
-T 不显示线程thread,默认显示线程
-u 显示用户切换
-H pid 高亮指定进程及其前辈进程
范例:
[root@rocky8 ~]# pstree
systemd─┬─NetworkManager───2*[{NetworkManager}]
├─VGAuthService
├─agetty
├─anacron
├─auditd───{auditd}
├─crond
├─dbus-daemon
├─polkitd───5*[{polkitd}]
├─rsyslogd───2*[{rsyslogd}]
├─sshd─┬─sshd───sshd───bash───pstree
│ └─sshd───sshd───bash───vim
├─sssd─┬─sssd_be
│ └─sssd_nss
├─systemd───(sd-pam)
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─tuned───3*[{tuned}]
└─vmtoolsd───2*[{vmtoolsd}]
[root@rocky8 ~]# pstree -p
systemd(1)─┬─NetworkManager(728)─┬─{NetworkManager}(756)
│ └─{NetworkManager}(759)
├─VGAuthService(718)
├─agetty(855)
├─anacron(10005)
├─auditd(685)───{auditd}(686)
├─crond(843)
├─dbus-daemon(726)
├─polkitd(723)─┬─{polkitd}(751)
│ ├─{polkitd}(768)
│ ├─{polkitd}(776)
│ ├─{polkitd}(777)
│ └─{polkitd}(823)
├─rsyslogd(837)─┬─{rsyslogd}(850)
│ └─{rsyslogd}(852)
├─sshd(765)─┬─sshd(9473)───sshd(9475)───bash(9476)───pstree(10012)
│ └─sshd(9509)───sshd(9511)───bash(9512)───vim(9994)
├─sssd(721)─┬─sssd_be(773)
│ └─sssd_nss(809)
├─systemd(1302)───(sd-pam)(1305)
├─systemd-journal(601)
├─systemd-logind(838)
├─systemd-udevd(635)
├─tuned(767)─┬─{tuned}(1143)
│ ├─{tuned}(1158)
│ └─{tuned}(1163)
└─vmtoolsd(719)─┬─{vmtoolsd}(757)
└─{vmtoolsd}(778)
[root@rocky8 ~]# pstree 9512
bash───vim
[root@rocky8 ~]# pstree -p 9512
bash(9512)───vim(9994)
[root@rocky8 ~]# pstree -pH 9512
systemd(1)─┬─NetworkManager(728)─┬─{NetworkManager}(756)
│ └─{NetworkManager}(759)
├─VGAuthService(718)
├─agetty(855)
├─anacron(10005)
├─auditd(685)───{auditd}(686)
├─crond(843)
├─dbus-daemon(726)
├─polkitd(723)─┬─{polkitd}(751)
│ ├─{polkitd}(768)
│ ├─{polkitd}(776)
│ ├─{polkitd}(777)
│ └─{polkitd}(823)
├─rsyslogd(837)─┬─{rsyslogd}(850)
│ └─{rsyslogd}(852)
├─sshd(765)─┬─sshd(9473)───sshd(9475)───bash(9476)───pstree(10015)
│ └─sshd(9509)───sshd(9511)───bash(9512)───vim(9994)
├─sssd(721)─┬─sssd_be(773)
│ └─sssd_nss(809)
├─systemd(1302)───(sd-pam)(1305)
├─systemd-journal(601)
├─systemd-logind(838)
├─systemd-udevd(635)
├─tuned(767)─┬─{tuned}(1143)
│ ├─{tuned}(1158)
│ └─{tuned}(1163)
└─vmtoolsd(719)─┬─{vmtoolsd}(757)
└─{vmtoolsd}(778)
#H 高亮显示
[root@rocky8 ~]# echo $BASHPID
9476
[root@rocky8 ~]# su - raymond
Last login: Sun Oct 31 14:12:13 CST 2021 on pts/1
[raymond@rocky8 ~]$
#新开终端
[root@rocky8 ~]# pstree -pu 9476
bash(9476)───su(10058)───bash(10059,raymond)
#u 显示用户身份切换过程
[root@rocky8 ~]# pstree -p |grep bash
|-sshd(765)-+-sshd(9473)---sshd(9475)---bash(9476)---su(10058)---bash(10059)
| `-sshd(9509)---sshd(9511)---bash(9512)-+-grep(10088)
范例:
[raymond@rocky8 ~]$ ping 172.31.0.7
PING 172.31.0.7 (172.31.0.7) 56(84) bytes of data.
64 bytes from 172.31.0.7: icmp_seq=1 ttl=64 time=0.867 ms
64 bytes from 172.31.0.7: icmp_seq=2 ttl=64 time=0.509 ms
[root@rocky8 ~]# pstree 1
systemd─┬─NetworkManager───2*[{NetworkManager}]
├─VGAuthService
├─agetty
├─anacron
├─auditd───{auditd}
├─crond
├─dbus-daemon
├─polkitd───5*[{polkitd}]
├─rsyslogd───2*[{rsyslogd}]
├─sshd─┬─sshd───sshd───bash───su───bash───ping
│ └─sshd───sshd───bash───pstree
├─sssd─┬─sssd_be
│ └─sssd_nss
├─systemd───(sd-pam)
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─tuned───3*[{tuned}]
└─vmtoolsd───2*[{vmtoolsd}]
[root@rocky8 ~]# pstree raymond
bash───ping
[root@rocky8 ~]# pstree -T
systemd─┬─NetworkManager
├─VGAuthService
├─agetty
├─anacron
├─auditd
├─crond
├─dbus-daemon
├─polkitd
├─rsyslogd
├─sshd─┬─sshd───sshd───bash───su───bash───ping
│ └─sshd───sshd───bash───pstree
├─sssd─┬─sssd_be
│ └─sssd_nss
├─systemd───(sd-pam)
├─systemd-journal
├─systemd-logind
├─systemd-udevd
├─tuned
└─vmtoolsd
[root@rocky8 ~]# pstree -pT
systemd(1)─┬─NetworkManager(728)
├─VGAuthService(718)
├─agetty(855)
├─anacron(10005)
├─auditd(685)
├─crond(843)
├─dbus-daemon(726)
├─polkitd(723)
├─rsyslogd(837)
├─sshd(765)─┬─sshd(9473)───sshd(9475)───bash(9476)───su(10092)───bash(10093)───ping(10123)
│ └─sshd(9509)───sshd(9511)───bash(9512)───pstree(10127)
├─sssd(721)─┬─sssd_be(773)
│ └─sssd_nss(809)
├─systemd(1302)───(sd-pam)(1305)
├─systemd-journal(601)
├─systemd-logind(838)
├─systemd-udevd(635)
├─tuned(767)
└─vmtoolsd(719)
2.2 进程信息 ps
ps 即process state,可以进程当前状态的快照,默认显示当前终端中的进程,Linux系统各进程的相关信息均保存在/proc/PID目录下的各文件中
ps格式
ps [OPTION]...
支持三种选项:
- UNIX选项 如: -A -e
- GNU选项 如: --help
- BSD选项 如: a
常用选项:
a 选项包括所有终端中的进程
x 选项包括不链接终端的进程
u 选项显示进程所有者的信息
f 选项显示进程树,相当于 --forest
k|--sort 属性 对属性排序,属性前加 - 表示倒序
o 属性… 选项显示定制的信息 pid、cmd、%cpu、%mem
L 显示支持的属性列表
-C cmdlist 指定命令,多个命令用,分隔
-L 显示线程
-e 显示所有进程,相当于-A
-f 显示完整格式程序信息
-F 显示更完整格式的进程信息
-H 以进程层级格式显示进程相关信息
-u userlist 指定有效的用户ID或名称
-U userlist 指定真正的用户ID或名称
-g gid或groupname 指定有效的gid或组名称
-G gid或groupname 指定真正的gid或组名称
-p pid 显示指pid的进程
--ppid pid 显示属于pid的子进程
-t ttylist 指定tty,相当于 t
-M 显示SELinux信息,相当于Z
ps 输出属性
C : ps -ef 显示列 C 表示cpu利用率
VSZ: Virtual memory SiZe,虚拟内存集,线性内存
RSS: ReSident Size, 常驻内存集
STAT:进程状态
R:running
S: interruptable sleeping
D: uninterruptable sleeping
T: stopped
Z: zombie
+: 前台进程
l: 多线程进程
L:内存分页并带锁
N:低优先级进程
<: 高优先级进程
s: session leader,会话(子进程)发起者
I:Idle kernel thread,新内核新特性
ni: nice值
pri: priority 优先级
rtprio: 实时优先级
psr: processor CPU编号
示例:
ps axo pid,cmd,psr,ni,pri,rtprio
常用组合:
aux
-ef
-eFH
-eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,comm
axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
范例:
[root@rocky8 ~]# man ps
PS(1) User Commands PS(1)
NAME
ps - report a snapshot of the current processes.
SYNOPSIS
ps [options]
DESCRIPTION
ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the
displayed information, use top(1) instead.
This version of ps accepts several kinds of options:
1 UNIX options, which may be grouped and must be preceded by a dash.
2 BSD options, which may be grouped and must not be used with a dash.
3 GNU long options, which are preceded by two dashes.
...
[root@rocky8 ~]# ps
PID TTY TIME CMD
9512 pts/0 00:00:00 bash
10147 pts/0 00:00:00 ps
#ps 默认显示当前窗口执行的进程
[root@rocky8 ~]# ps aux |grep pts/0
root 9511 0.0 0.8 153404 6900 ? S 13:50 0:00 sshd: root@pts/0
root 9512 0.0 0.5 26244 4016 pts/0 Ss 13:50 0:00 -bash
root 10148 0.0 0.4 58728 3928 pts/0 R+ 14:26 0:00 ps aux
root 10149 0.0 0.1 12136 1092 pts/0 S+ 14:26 0:00 grep --color=auto pts/0
[root@rocky8 ~]# ps a
PID TTY STAT TIME COMMAND
855 tty1 Ss+ 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
9476 pts/1 Ss 0:00 -bash
9512 pts/0 Ss 0:00 -bash
10092 pts/1 S 0:00 su - raymond
10093 pts/1 S 0:00 -bash
10123 pts/1 S+ 0:00 ping 172.31.0.7
10150 pts/0 R+ 0:00 ps a
#a 表示所有终端上相关进行运行的信息
[root@rocky8 ~]# ps -a
PID TTY TIME CMD
10092 pts/1 00:00:00 su
10093 pts/1 00:00:00 bash
10123 pts/1 00:00:00 ping
10151 pts/0 00:00:00 ps
[root@rocky8 ~]# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
2 ? S 0:00 [kthreadd]
3 ? I< 0:00 [rcu_gp]
4 ? I< 0:00 [rcu_par_gp]
6 ? I< 0:00 [kworker/0:0H-events_highpri]
9 ? I< 0:00 [mm_percpu_wq]
10 ? S 0:00 [ksoftirqd/0]
11 ? R 0:00 [rcu_sched]
12 ? S 0:00 [migration/0]
13 ? S 0:00 [watchdog/0]
14 ? S 0:00 [cpuhp/0]
16 ? S 0:00 [kdevtmpfs]
17 ? I< 0:00 [netns]
18 ? S 0:00 [kauditd]
19 ? S 0:00 [khungtaskd]
20 ? S 0:00 [oom_reaper]
21 ? I< 0:00 [writeback]
22 ? S 0:00 [kcompactd0]
23 ? SN 0:00 [ksmd]
24 ? SN 0:00 [khugepaged]
25 ? I< 0:00 [crypto]
26 ? I< 0:00 [kintegrityd]
27 ? I< 0:00 [kblockd]
28 ? I< 0:00 [blkcg_punt_bio]
29 ? I< 0:00 [tpm_dev_wq]
30 ? I< 0:00 [md]
31 ? I< 0:00 [edac-poller]
32 ? S 0:00 [watchdogd]
33 ? I< 0:00 [kworker/0:1H-kblockd]
35 ? R 0:00 [kworker/u256:1-events_unbound]
61 ? S 0:00 [kswapd0]
154 ? I< 0:00 [kthrotld]
155 ? S 0:00 [irq/24-pciehp]
156 ? S 0:00 [irq/25-pciehp]
157 ? S 0:00 [irq/26-pciehp]
158 ? S 0:00 [irq/27-pciehp]
159 ? S 0:00 [irq/28-pciehp]
160 ? S 0:00 [irq/29-pciehp]
161 ? S 0:00 [irq/30-pciehp]
162 ? S 0:00 [irq/31-pciehp]
163 ? S 0:00 [irq/32-pciehp]
164 ? S 0:00 [irq/33-pciehp]
165 ? S 0:00 [irq/34-pciehp]
166 ? S 0:00 [irq/35-pciehp]
167 ? S 0:00 [irq/36-pciehp]
168 ? S 0:00 [irq/37-pciehp]
169 ? S 0:00 [irq/38-pciehp]
170 ? S 0:00 [irq/39-pciehp]
171 ? S 0:00 [irq/40-pciehp]
172 ? S 0:00 [irq/41-pciehp]
173 ? S 0:00 [irq/42-pciehp]
174 ? S 0:00 [irq/43-pciehp]
175 ? S 0:00 [irq/44-pciehp]
176 ? S 0:00 [irq/45-pciehp]
177 ? S 0:00 [irq/46-pciehp]
178 ? S 0:00 [irq/47-pciehp]
179 ? S 0:00 [irq/48-pciehp]
180 ? S 0:00 [irq/49-pciehp]
181 ? S 0:00 [irq/50-pciehp]
182 ? S 0:00 [irq/51-pciehp]
183 ? S 0:00 [irq/52-pciehp]
184 ? S 0:00 [irq/53-pciehp]
185 ? S 0:00 [irq/54-pciehp]
186 ? S 0:00 [irq/55-pciehp]
187 ? I< 0:00 [acpi_thermal_pm]
188 ? I< 0:00 [kmpath_rdacd]
189 ? I< 0:00 [kaluad]
190 ? I< 0:00 [ipv6_addrconf]
191 ? I< 0:00 [kstrp]
448 ? I< 0:00 [mpt_poll_0]
449 ? I< 0:00 [ata_sff]
450 ? I< 0:00 [mpt/0]
451 ? S 0:00 [scsi_eh_0]
452 ? I< 0:00 [scsi_tmf_0]
453 ? S 0:00 [scsi_eh_1]
454 ? I< 0:00 [scsi_tmf_1]
459 ? S 0:00 [scsi_eh_2]
460 ? I< 0:00 [scsi_tmf_2]
468 ? S 0:00 [irq/16-vmwgfx]
470 ? I< 0:00 [ttm_swap]
471 ? S 0:00 [card0-crtc0]
472 ? S 0:00 [card0-crtc1]
473 ? S 0:00 [card0-crtc2]
474 ? S 0:00 [card0-crtc3]
475 ? S 0:00 [card0-crtc4]
476 ? S 0:00 [card0-crtc5]
477 ? S 0:00 [card0-crtc6]
478 ? S 0:00 [card0-crtc7]
503 ? I< 0:00 [xfsalloc]
504 ? I< 0:00 [xfs_mru_cache]
505 ? I< 0:00 [xfs-buf/sda2]
506 ? I< 0:00 [xfs-conv/sda2]
507 ? I< 0:00 [xfs-cil/sda2]
508 ? I< 0:00 [xfs-reclaim/sda]
509 ? I< 0:00 [xfs-eofblocks/s]
510 ? I< 0:00 [xfs-log/sda2]
511 ? S 0:00 [xfsaild/sda2]
601 ? Ss 0:00 /usr/lib/systemd/systemd-journald
635 ? Ss 0:00 /usr/lib/systemd/systemd-udevd
639 ? I< 0:00 [xfs-buf/sda3]
640 ? I< 0:00 [xfs-conv/sda3]
641 ? I< 0:00 [xfs-buf/sda1]
642 ? I< 0:00 [xfs-cil/sda3]
643 ? I< 0:00 [xfs-conv/sda1]
644 ? I< 0:00 [xfs-reclaim/sda]
645 ? I< 0:00 [xfs-cil/sda1]
646 ? I< 0:00 [xfs-eofblocks/s]
647 ? I< 0:00 [xfs-reclaim/sda]
648 ? I< 0:00 [xfs-log/sda3]
649 ? I< 0:00 [xfs-eofblocks/s]
650 ? S 0:00 [xfsaild/sda3]
651 ? I< 0:00 [xfs-log/sda1]
652 ? S 0:00 [xfsaild/sda1]
685 ? S<sl 0:00 /sbin/auditd
718 ? Ss 0:00 /usr/bin/VGAuthService -s
719 ? Ssl 0:06 /usr/bin/vmtoolsd
721 ? Ss 0:00 /usr/sbin/sssd -i --logger=files
723 ? Ssl 0:00 /usr/lib/polkit-1/polkitd --no-debug
726 ? Ss 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
728 ? Ssl 0:00 /usr/sbin/NetworkManager --no-daemon
765 ? Ss 0:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@
767 ? Ssl 0:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
773 ? S 0:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
779 ? I< 0:00 [kworker/u257:0-hci0]
783 ? I< 0:00 [kworker/u257:1-hci0]
809 ? S 0:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
837 ? Ssl 0:00 /usr/sbin/rsyslogd -n
838 ? Ss 0:00 /usr/lib/systemd/systemd-logind
843 ? Ss 0:00 /usr/sbin/crond -n
855 tty1 Ss+ 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
1302 ? Ss 0:00 /usr/lib/systemd/systemd --user
1305 ? S 0:00 (sd-pam)
9473 ? Ss 0:00 sshd: root [priv]
9475 ? S 0:00 sshd: root@pts/1
9476 pts/1 Ss 0:00 -bash
9509 ? Ss 0:00 sshd: root [priv]
9511 ? S 0:00 sshd: root@pts/0
9512 pts/0 Ss 0:00 -bash
9556 ? I 0:00 [kworker/u256:0-events_unbound]
9993 ? I 0:03 [kworker/0:3-ata_sff]
10005 ? Ss 0:00 /usr/sbin/anacron -s
10092 pts/1 S 0:00 su - raymond
10093 pts/1 S 0:00 -bash
10123 pts/1 S+ 0:00 ping 172.31.0.7
10128 ? I 0:00 [kworker/0:1-xfs-buf/sda2]
10152 ? I 0:00 [kworker/0:0-events]
10153 pts/0 R+ 0:00 ps ax
#x 显示所有和终端无关的进程
[root@rocky8 ~]# ps x|wc -l
145
[root@rocky8 ~]# ps ax|wc -l
149
[root@rocky8 ~]# ps aux|wc -l
149
[root@rocky8 ~]# ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 1.4 183604 11400 ? Ss 13:03 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
root 2 0.0 0.0 0 0 ? S 13:03 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 13:03 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 13:03 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 13:03 0:00 [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I< 13:03 0:00 [mm_percpu_wq]
root 10 0.0 0.0 0 0 ? S 13:03 0:00 [ksoftirqd/0]
root 11 0.0 0.0 0 0 ? I 13:03 0:00 [rcu_sched]
root 12 0.0 0.0 0 0 ? S 13:03 0:00 [migration/0]
root 13 0.0 0.0 0 0 ? S 13:03 0:00 [watchdog/0]
root 14 0.0 0.0 0 0 ? S 13:03 0:00 [cpuhp/0]
root 16 0.0 0.0 0 0 ? S 13:03 0:00 [kdevtmpfs]
root 17 0.0 0.0 0 0 ? I< 13:03 0:00 [netns]
root 18 0.0 0.0 0 0 ? S 13:03 0:00 [kauditd]
root 19 0.0 0.0 0 0 ? S 13:03 0:00 [khungtaskd]
root 20 0.0 0.0 0 0 ? S 13:03 0:00 [oom_reaper]
root 21 0.0 0.0 0 0 ? I< 13:03 0:00 [writeback]
root 22 0.0 0.0 0 0 ? S 13:03 0:00 [kcompactd0]
root 23 0.0 0.0 0 0 ? SN 13:03 0:00 [ksmd]
root 24 0.0 0.0 0 0 ? SN 13:03 0:00 [khugepaged]
root 25 0.0 0.0 0 0 ? I< 13:03 0:00 [crypto]
root 26 0.0 0.0 0 0 ? I< 13:03 0:00 [kintegrityd]
root 27 0.0 0.0 0 0 ? I< 13:03 0:00 [kblockd]
root 28 0.0 0.0 0 0 ? I< 13:03 0:00 [blkcg_punt_bio]
root 29 0.0 0.0 0 0 ? I< 13:03 0:00 [tpm_dev_wq]
root 30 0.0 0.0 0 0 ? I< 13:03 0:00 [md]
root 31 0.0 0.0 0 0 ? I< 13:03 0:00 [edac-poller]
root 32 0.0 0.0 0 0 ? S 13:03 0:00 [watchdogd]
root 33 0.0 0.0 0 0 ? I< 13:03 0:00 [kworker/0:1H-kblockd]
root 35 0.0 0.0 0 0 ? R 13:03 0:00 [kworker/u256:1-events_unbound]
root 61 0.0 0.0 0 0 ? S 13:03 0:00 [kswapd0]
root 154 0.0 0.0 0 0 ? I< 13:03 0:00 [kthrotld]
root 155 0.0 0.0 0 0 ? S 13:03 0:00 [irq/24-pciehp]
root 156 0.0 0.0 0 0 ? S 13:03 0:00 [irq/25-pciehp]
root 157 0.0 0.0 0 0 ? S 13:03 0:00 [irq/26-pciehp]
root 158 0.0 0.0 0 0 ? S 13:03 0:00 [irq/27-pciehp]
root 159 0.0 0.0 0 0 ? S 13:03 0:00 [irq/28-pciehp]
root 160 0.0 0.0 0 0 ? S 13:03 0:00 [irq/29-pciehp]
root 161 0.0 0.0 0 0 ? S 13:03 0:00 [irq/30-pciehp]
root 162 0.0 0.0 0 0 ? S 13:03 0:00 [irq/31-pciehp]
root 163 0.0 0.0 0 0 ? S 13:03 0:00 [irq/32-pciehp]
root 164 0.0 0.0 0 0 ? S 13:03 0:00 [irq/33-pciehp]
root 165 0.0 0.0 0 0 ? S 13:03 0:00 [irq/34-pciehp]
root 166 0.0 0.0 0 0 ? S 13:03 0:00 [irq/35-pciehp]
root 167 0.0 0.0 0 0 ? S 13:03 0:00 [irq/36-pciehp]
root 168 0.0 0.0 0 0 ? S 13:03 0:00 [irq/37-pciehp]
root 169 0.0 0.0 0 0 ? S 13:03 0:00 [irq/38-pciehp]
root 170 0.0 0.0 0 0 ? S 13:03 0:00 [irq/39-pciehp]
root 171 0.0 0.0 0 0 ? S 13:03 0:00 [irq/40-pciehp]
root 172 0.0 0.0 0 0 ? S 13:03 0:00 [irq/41-pciehp]
root 173 0.0 0.0 0 0 ? S 13:03 0:00 [irq/42-pciehp]
root 174 0.0 0.0 0 0 ? S 13:03 0:00 [irq/43-pciehp]
root 175 0.0 0.0 0 0 ? S 13:03 0:00 [irq/44-pciehp]
root 176 0.0 0.0 0 0 ? S 13:03 0:00 [irq/45-pciehp]
root 177 0.0 0.0 0 0 ? S 13:03 0:00 [irq/46-pciehp]
root 178 0.0 0.0 0 0 ? S 13:03 0:00 [irq/47-pciehp]
root 179 0.0 0.0 0 0 ? S 13:03 0:00 [irq/48-pciehp]
root 180 0.0 0.0 0 0 ? S 13:03 0:00 [irq/49-pciehp]
root 181 0.0 0.0 0 0 ? S 13:03 0:00 [irq/50-pciehp]
root 182 0.0 0.0 0 0 ? S 13:03 0:00 [irq/51-pciehp]
root 183 0.0 0.0 0 0 ? S 13:03 0:00 [irq/52-pciehp]
root 184 0.0 0.0 0 0 ? S 13:03 0:00 [irq/53-pciehp]
root 185 0.0 0.0 0 0 ? S 13:03 0:00 [irq/54-pciehp]
root 186 0.0 0.0 0 0 ? S 13:03 0:00 [irq/55-pciehp]
root 187 0.0 0.0 0 0 ? I< 13:03 0:00 [acpi_thermal_pm]
root 188 0.0 0.0 0 0 ? I< 13:03 0:00 [kmpath_rdacd]
root 189 0.0 0.0 0 0 ? I< 13:03 0:00 [kaluad]
root 190 0.0 0.0 0 0 ? I< 13:03 0:00 [ipv6_addrconf]
root 191 0.0 0.0 0 0 ? I< 13:03 0:00 [kstrp]
root 448 0.0 0.0 0 0 ? I< 13:03 0:00 [mpt_poll_0]
root 449 0.0 0.0 0 0 ? I< 13:03 0:00 [ata_sff]
root 450 0.0 0.0 0 0 ? I< 13:03 0:00 [mpt/0]
root 451 0.0 0.0 0 0 ? S 13:03 0:00 [scsi_eh_0]
root 452 0.0 0.0 0 0 ? I< 13:03 0:00 [scsi_tmf_0]
root 453 0.0 0.0 0 0 ? S 13:03 0:00 [scsi_eh_1]
root 454 0.0 0.0 0 0 ? I< 13:03 0:00 [scsi_tmf_1]
root 459 0.0 0.0 0 0 ? S 13:03 0:00 [scsi_eh_2]
root 460 0.0 0.0 0 0 ? I< 13:03 0:00 [scsi_tmf_2]
root 468 0.0 0.0 0 0 ? S 13:03 0:00 [irq/16-vmwgfx]
root 470 0.0 0.0 0 0 ? I< 13:03 0:00 [ttm_swap]
root 471 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc0]
root 472 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc1]
root 473 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc2]
root 474 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc3]
root 475 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc4]
root 476 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc5]
root 477 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc6]
root 478 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc7]
root 503 0.0 0.0 0 0 ? I< 13:03 0:00 [xfsalloc]
root 504 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs_mru_cache]
root 505 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-buf/sda2]
root 506 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-conv/sda2]
root 507 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-cil/sda2]
root 508 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-reclaim/sda]
root 509 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-eofblocks/s]
root 510 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-log/sda2]
root 511 0.0 0.0 0 0 ? S 13:03 0:00 [xfsaild/sda2]
root 601 0.0 1.1 97744 9268 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-journald
root 635 0.0 1.2 124580 10004 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-udevd
root 639 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-buf/sda3]
root 640 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-conv/sda3]
root 641 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-buf/sda1]
root 642 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-cil/sda3]
root 643 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-conv/sda1]
root 644 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-reclaim/sda]
root 645 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-cil/sda1]
root 646 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-eofblocks/s]
root 647 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-reclaim/sda]
root 648 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-log/sda3]
root 649 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-eofblocks/s]
root 650 0.0 0.0 0 0 ? S 13:03 0:00 [xfsaild/sda3]
root 651 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-log/sda1]
root 652 0.0 0.0 0 0 ? S 13:03 0:00 [xfsaild/sda1]
root 685 0.0 0.3 67960 2656 ? S<sl 13:03 0:00 /sbin/auditd
root 718 0.0 1.4 86200 11416 ? Ss 13:03 0:00 /usr/bin/VGAuthService -s
root 719 0.1 1.2 278328 10044 ? Ssl 13:03 0:06 /usr/bin/vmtoolsd
root 721 0.0 1.7 216924 14320 ? Ss 13:03 0:00 /usr/sbin/sssd -i --logger=files
polkitd 723 0.0 3.0 1630348 24108 ? Ssl 13:03 0:00 /usr/lib/polkit-1/polkitd --no-debug
dbus 726 0.0 0.6 76628 5504 ? Ss 13:03 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --syst
root 728 0.0 2.2 391536 18224 ? Ssl 13:03 0:00 /usr/sbin/NetworkManager --no-daemon
root 765 0.0 1.0 94444 8036 ? Ss 13:03 0:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh
root 767 0.0 3.7 414624 30244 ? Ssl 13:03 0:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
root 773 0.0 1.8 225680 15080 ? S 13:03 0:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=f
root 779 0.0 0.0 0 0 ? I< 13:03 0:00 [kworker/u257:0-hci0]
root 783 0.0 0.0 0 0 ? I< 13:03 0:00 [kworker/u257:1-hci0]
root 809 0.0 5.1 226992 40888 ? S 13:03 0:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root 837 0.0 0.6 215336 5328 ? Ssl 13:03 0:00 /usr/sbin/rsyslogd -n
root 838 0.0 1.0 103976 8328 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-logind
root 843 0.0 0.4 36956 3604 ? Ss 13:03 0:00 /usr/sbin/crond -n
root 855 0.0 0.2 13656 1724 tty1 Ss+ 13:03 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root 1302 0.0 1.2 100692 9904 ? Ss 13:04 0:00 /usr/lib/systemd/systemd --user
root 1305 0.0 0.3 238892 2588 ? S 13:04 0:00 (sd-pam)
root 9473 0.0 1.1 139184 9436 ? Ss 13:47 0:00 sshd: root [priv]
root 9475 0.0 0.8 153404 6828 ? S 13:47 0:00 sshd: root@pts/1
root 9476 0.0 0.4 26244 3832 pts/1 Ss 13:47 0:00 -bash
root 9509 0.0 1.0 139184 8756 ? Ss 13:50 0:00 sshd: root [priv]
root 9511 0.0 0.8 153404 6900 ? S 13:50 0:00 sshd: root@pts/0
root 9512 0.0 0.5 26244 4016 pts/0 Ss 13:50 0:00 -bash
root 9556 0.0 0.0 0 0 ? I 14:00 0:00 [kworker/u256:0-events_unbound]
root 9993 0.1 0.0 0 0 ? I 14:00 0:03 [kworker/0:3-ata_sff]
root 10005 0.0 0.2 22764 2036 ? Ss 14:01 0:00 /usr/sbin/anacron -s
root 10092 0.0 0.7 127212 6112 pts/1 S 14:16 0:00 su - raymond
raymond 10093 0.0 0.4 24120 3912 pts/1 S 14:16 0:00 -bash
raymond 10123 0.0 0.3 32448 2448 pts/1 S+ 14:16 0:00 ping 172.31.0.7
root 10128 0.0 0.0 0 0 ? I 14:21 0:00 [kworker/0:1-xfs-buf/sda2]
root 10152 0.1 0.0 0 0 ? I 14:27 0:00 [kworker/0:0-events]
root 10160 0.0 0.4 58728 3984 pts/0 R+ 14:28 0:00 ps axu
#u 显示更加详细的进程信息
# USER 用户信息 PID 进程ID %CPU CPU使用率 %MEM 内存使用率 VSZ 虚拟内存使用率(操作系统承诺分配内存大小) RSS 实际物理内存使用率(实际使用物理内存大小) TTY 终端 STAT 状态 START 什么时候启动的 TIME 累计占用系统的时间 COMMAND 执行的命令
[root@rocky8 ~]# ps -ef |wc -l
149
[root@rocky8 ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 13:03 ? 00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
root 2 0 0 13:03 ? 00:00:00 [kthreadd]
root 3 2 0 13:03 ? 00:00:00 [rcu_gp]
root 4 2 0 13:03 ? 00:00:00 [rcu_par_gp]
root 6 2 0 13:03 ? 00:00:00 [kworker/0:0H-events_highpri]
root 9 2 0 13:03 ? 00:00:00 [mm_percpu_wq]
root 10 2 0 13:03 ? 00:00:00 [ksoftirqd/0]
root 11 2 0 13:03 ? 00:00:00 [rcu_sched]
root 12 2 0 13:03 ? 00:00:00 [migration/0]
root 13 2 0 13:03 ? 00:00:00 [watchdog/0]
root 14 2 0 13:03 ? 00:00:00 [cpuhp/0]
root 16 2 0 13:03 ? 00:00:00 [kdevtmpfs]
root 17 2 0 13:03 ? 00:00:00 [netns]
root 18 2 0 13:03 ? 00:00:00 [kauditd]
root 19 2 0 13:03 ? 00:00:00 [khungtaskd]
root 20 2 0 13:03 ? 00:00:00 [oom_reaper]
root 21 2 0 13:03 ? 00:00:00 [writeback]
root 22 2 0 13:03 ? 00:00:00 [kcompactd0]
root 23 2 0 13:03 ? 00:00:00 [ksmd]
root 24 2 0 13:03 ? 00:00:00 [khugepaged]
root 25 2 0 13:03 ? 00:00:00 [crypto]
root 26 2 0 13:03 ? 00:00:00 [kintegrityd]
root 27 2 0 13:03 ? 00:00:00 [kblockd]
root 28 2 0 13:03 ? 00:00:00 [blkcg_punt_bio]
root 29 2 0 13:03 ? 00:00:00 [tpm_dev_wq]
root 30 2 0 13:03 ? 00:00:00 [md]
root 31 2 0 13:03 ? 00:00:00 [edac-poller]
root 32 2 0 13:03 ? 00:00:00 [watchdogd]
root 33 2 0 13:03 ? 00:00:00 [kworker/0:1H-kblockd]
root 35 2 0 13:03 ? 00:00:00 [kworker/u256:1-events_unbound]
root 61 2 0 13:03 ? 00:00:00 [kswapd0]
root 154 2 0 13:03 ? 00:00:00 [kthrotld]
root 155 2 0 13:03 ? 00:00:00 [irq/24-pciehp]
root 156 2 0 13:03 ? 00:00:00 [irq/25-pciehp]
root 157 2 0 13:03 ? 00:00:00 [irq/26-pciehp]
root 158 2 0 13:03 ? 00:00:00 [irq/27-pciehp]
root 159 2 0 13:03 ? 00:00:00 [irq/28-pciehp]
root 160 2 0 13:03 ? 00:00:00 [irq/29-pciehp]
root 161 2 0 13:03 ? 00:00:00 [irq/30-pciehp]
root 162 2 0 13:03 ? 00:00:00 [irq/31-pciehp]
root 163 2 0 13:03 ? 00:00:00 [irq/32-pciehp]
root 164 2 0 13:03 ? 00:00:00 [irq/33-pciehp]
root 165 2 0 13:03 ? 00:00:00 [irq/34-pciehp]
root 166 2 0 13:03 ? 00:00:00 [irq/35-pciehp]
root 167 2 0 13:03 ? 00:00:00 [irq/36-pciehp]
root 168 2 0 13:03 ? 00:00:00 [irq/37-pciehp]
root 169 2 0 13:03 ? 00:00:00 [irq/38-pciehp]
root 170 2 0 13:03 ? 00:00:00 [irq/39-pciehp]
root 171 2 0 13:03 ? 00:00:00 [irq/40-pciehp]
root 172 2 0 13:03 ? 00:00:00 [irq/41-pciehp]
root 173 2 0 13:03 ? 00:00:00 [irq/42-pciehp]
root 174 2 0 13:03 ? 00:00:00 [irq/43-pciehp]
root 175 2 0 13:03 ? 00:00:00 [irq/44-pciehp]
root 176 2 0 13:03 ? 00:00:00 [irq/45-pciehp]
root 177 2 0 13:03 ? 00:00:00 [irq/46-pciehp]
root 178 2 0 13:03 ? 00:00:00 [irq/47-pciehp]
root 179 2 0 13:03 ? 00:00:00 [irq/48-pciehp]
root 180 2 0 13:03 ? 00:00:00 [irq/49-pciehp]
root 181 2 0 13:03 ? 00:00:00 [irq/50-pciehp]
root 182 2 0 13:03 ? 00:00:00 [irq/51-pciehp]
root 183 2 0 13:03 ? 00:00:00 [irq/52-pciehp]
root 184 2 0 13:03 ? 00:00:00 [irq/53-pciehp]
root 185 2 0 13:03 ? 00:00:00 [irq/54-pciehp]
root 186 2 0 13:03 ? 00:00:00 [irq/55-pciehp]
root 187 2 0 13:03 ? 00:00:00 [acpi_thermal_pm]
root 188 2 0 13:03 ? 00:00:00 [kmpath_rdacd]
root 189 2 0 13:03 ? 00:00:00 [kaluad]
root 190 2 0 13:03 ? 00:00:00 [ipv6_addrconf]
root 191 2 0 13:03 ? 00:00:00 [kstrp]
root 448 2 0 13:03 ? 00:00:00 [mpt_poll_0]
root 449 2 0 13:03 ? 00:00:00 [ata_sff]
root 450 2 0 13:03 ? 00:00:00 [mpt/0]
root 451 2 0 13:03 ? 00:00:00 [scsi_eh_0]
root 452 2 0 13:03 ? 00:00:00 [scsi_tmf_0]
root 453 2 0 13:03 ? 00:00:00 [scsi_eh_1]
root 454 2 0 13:03 ? 00:00:00 [scsi_tmf_1]
root 459 2 0 13:03 ? 00:00:00 [scsi_eh_2]
root 460 2 0 13:03 ? 00:00:00 [scsi_tmf_2]
root 468 2 0 13:03 ? 00:00:00 [irq/16-vmwgfx]
root 470 2 0 13:03 ? 00:00:00 [ttm_swap]
root 471 2 0 13:03 ? 00:00:00 [card0-crtc0]
root 472 2 0 13:03 ? 00:00:00 [card0-crtc1]
root 473 2 0 13:03 ? 00:00:00 [card0-crtc2]
root 474 2 0 13:03 ? 00:00:00 [card0-crtc3]
root 475 2 0 13:03 ? 00:00:00 [card0-crtc4]
root 476 2 0 13:03 ? 00:00:00 [card0-crtc5]
root 477 2 0 13:03 ? 00:00:00 [card0-crtc6]
root 478 2 0 13:03 ? 00:00:00 [card0-crtc7]
root 503 2 0 13:03 ? 00:00:00 [xfsalloc]
root 504 2 0 13:03 ? 00:00:00 [xfs_mru_cache]
root 505 2 0 13:03 ? 00:00:00 [xfs-buf/sda2]
root 506 2 0 13:03 ? 00:00:00 [xfs-conv/sda2]
root 507 2 0 13:03 ? 00:00:00 [xfs-cil/sda2]
root 508 2 0 13:03 ? 00:00:00 [xfs-reclaim/sda]
root 509 2 0 13:03 ? 00:00:00 [xfs-eofblocks/s]
root 510 2 0 13:03 ? 00:00:00 [xfs-log/sda2]
root 511 2 0 13:03 ? 00:00:00 [xfsaild/sda2]
root 601 1 0 13:03 ? 00:00:00 /usr/lib/systemd/systemd-journald
root 635 1 0 13:03 ? 00:00:00 /usr/lib/systemd/systemd-udevd
root 639 2 0 13:03 ? 00:00:00 [xfs-buf/sda3]
root 640 2 0 13:03 ? 00:00:00 [xfs-conv/sda3]
root 641 2 0 13:03 ? 00:00:00 [xfs-buf/sda1]
root 642 2 0 13:03 ? 00:00:00 [xfs-cil/sda3]
root 643 2 0 13:03 ? 00:00:00 [xfs-conv/sda1]
root 644 2 0 13:03 ? 00:00:00 [xfs-reclaim/sda]
root 645 2 0 13:03 ? 00:00:00 [xfs-cil/sda1]
root 646 2 0 13:03 ? 00:00:00 [xfs-eofblocks/s]
root 647 2 0 13:03 ? 00:00:00 [xfs-reclaim/sda]
root 648 2 0 13:03 ? 00:00:00 [xfs-log/sda3]
root 649 2 0 13:03 ? 00:00:00 [xfs-eofblocks/s]
root 650 2 0 13:03 ? 00:00:00 [xfsaild/sda3]
root 651 2 0 13:03 ? 00:00:00 [xfs-log/sda1]
root 652 2 0 13:03 ? 00:00:00 [xfsaild/sda1]
root 685 1 0 13:03 ? 00:00:00 /sbin/auditd
root 718 1 0 13:03 ? 00:00:00 /usr/bin/VGAuthService -s
root 719 1 0 13:03 ? 00:00:06 /usr/bin/vmtoolsd
root 721 1 0 13:03 ? 00:00:00 /usr/sbin/sssd -i --logger=files
polkitd 723 1 0 13:03 ? 00:00:00 /usr/lib/polkit-1/polkitd --no-debug
dbus 726 1 0 13:03 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 728 1 0 13:03 ? 00:00:00 /usr/sbin/NetworkManager --no-daemon
root 765 1 0 13:03 ? 00:00:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
root 767 1 0 13:03 ? 00:00:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
root 773 721 0 13:03 ? 00:00:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
root 779 2 0 13:03 ? 00:00:00 [kworker/u257:0-hci0]
root 783 2 0 13:03 ? 00:00:00 [kworker/u257:1-hci0]
root 809 721 0 13:03 ? 00:00:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root 837 1 0 13:03 ? 00:00:00 /usr/sbin/rsyslogd -n
root 838 1 0 13:03 ? 00:00:00 /usr/lib/systemd/systemd-logind
root 843 1 0 13:03 ? 00:00:00 /usr/sbin/crond -n
root 855 1 0 13:03 tty1 00:00:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root 1302 1 0 13:04 ? 00:00:00 /usr/lib/systemd/systemd --user
root 1305 1302 0 13:04 ? 00:00:00 (sd-pam)
root 9473 765 0 13:47 ? 00:00:00 sshd: root [priv]
root 9475 9473 0 13:47 ? 00:00:00 sshd: root@pts/1
root 9476 9475 0 13:47 pts/1 00:00:00 -bash
root 9509 765 0 13:50 ? 00:00:00 sshd: root [priv]
root 9511 9509 0 13:50 ? 00:00:00 sshd: root@pts/0
root 9512 9511 0 13:50 pts/0 00:00:00 -bash
root 9556 2 0 14:00 ? 00:00:00 [kworker/u256:0-events_unbound]
root 9993 2 0 14:00 ? 00:00:03 [kworker/0:3-ata_sff]
root 10005 1 0 14:01 ? 00:00:00 /usr/sbin/anacron -s
root 10092 9476 0 14:16 pts/1 00:00:00 su - raymond
raymond 10093 10092 0 14:16 pts/1 00:00:00 -bash
raymond 10123 10093 0 14:16 pts/1 00:00:00 ping 172.31.0.7
root 10128 2 0 14:21 ? 00:00:00 [kworker/0:1-xfs-buf/sda2]
root 10152 2 0 14:27 ? 00:00:00 [kworker/0:0-mm_percpu_wq]
root 10163 9512 0 14:30 pts/0 00:00:00 ps -ef
# ps -ef UNIX风格
范例:
[root@rocky8 ~]# dd if=/dev/zero of=/dev/null
[root@rocky8 ~]# ps aux |grep dd
root 2 0.0 0.0 0 0 ? S 13:03 0:00 [kthreadd]
root 190 0.0 0.0 0 0 ? I< 13:03 0:00 [ipv6_addrconf]
dbus 726 0.0 0.6 76628 5504 ? Ss 13:03 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root 10164 100 0.1 7352 948 pts/0 R+ 14:31 0:32 dd if=/dev/zero of=/dev/null
root 10166 0.0 0.1 12136 1120 pts/1 R+ 14:31 0:00 grep --color=auto dd
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem |grep dd
2 [kthreadd] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
10164 dd if=/dev/zero of=/dev/nul 99.5 0.1
10168 grep --color=auto dd 0.0 0.1
#o 指定显示特定的字段
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem k %cpu|grep dd
2 [kthreadd] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
10170 grep --color=auto dd 0.0 0.1
10164 dd if=/dev/zero of=/dev/nul 100 0.1
#k 指定排序方式
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem k -%cpu|grep dd
10164 dd if=/dev/zero of=/dev/nul 99.7 0.1
2 [kthreadd] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
10175 grep --color=auto dd 0.0 0.1
#倒序。加-
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem k -%mem
PID CMD %CPU %MEM
809 /usr/libexec/sssd/sssd_nss 0.0 5.1
767 /usr/libexec/platform-pytho 0.0 3.7
723 /usr/lib/polkit-1/polkitd - 0.0 3.0
728 /usr/sbin/NetworkManager -- 0.0 2.2
773 /usr/libexec/sssd/sssd_be - 0.0 1.8
721 /usr/sbin/sssd -i --logger= 0.0 1.7
718 /usr/bin/VGAuthService -s 0.0 1.4
1 /usr/lib/systemd/systemd -- 0.0 1.4
719 /usr/bin/vmtoolsd 0.1 1.2
635 /usr/lib/systemd/systemd-ud 0.0 1.2
1302 /usr/lib/systemd/systemd -- 0.0 1.2
9473 sshd: root [priv] 0.0 1.1
601 /usr/lib/systemd/systemd-jo 0.0 1.1
9509 sshd: root [priv] 0.0 1.0
838 /usr/lib/systemd/systemd-lo 0.0 1.0
765 /usr/sbin/sshd -D -oCiphers 0.0 1.0
9511 sshd: root@pts/0 0.0 0.8
9475 sshd: root@pts/1 0.0 0.8
726 /usr/bin/dbus-daemon --syst 0.0 0.6
837 /usr/sbin/rsyslogd -n 0.0 0.6
9512 -bash 0.0 0.5
9476 -bash 0.0 0.4
10176 ps axo pid,cmd,%cpu,%mem k 0.0 0.4
843 /usr/sbin/crond -n 0.0 0.4
685 /sbin/auditd 0.0 0.3
1305 (sd-pam) 0.0 0.3
10005 /usr/sbin/anacron -s 0.0 0.2
855 /sbin/agetty -o -p -- \u -- 0.0 0.2
10164 dd if=/dev/zero of=/dev/nul 99.3 0.1
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
4 [rcu_par_gp] 0.0 0.0
6 [kworker/0:0H-events_highpr 0.0 0.0
9 [mm_percpu_wq] 0.0 0.0
10 [ksoftirqd/0] 0.0 0.0
11 [rcu_sched] 0.0 0.0
12 [migration/0] 0.0 0.0
13 [watchdog/0] 0.0 0.0
14 [cpuhp/0] 0.0 0.0
16 [kdevtmpfs] 0.0 0.0
17 [netns] 0.0 0.0
18 [kauditd] 0.0 0.0
19 [khungtaskd] 0.0 0.0
20 [oom_reaper] 0.0 0.0
21 [writeback] 0.0 0.0
22 [kcompactd0] 0.0 0.0
23 [ksmd] 0.0 0.0
24 [khugepaged] 0.0 0.0
25 [crypto] 0.0 0.0
26 [kintegrityd] 0.0 0.0
27 [kblockd] 0.0 0.0
28 [blkcg_punt_bio] 0.0 0.0
29 [tpm_dev_wq] 0.0 0.0
30 [md] 0.0 0.0
31 [edac-poller] 0.0 0.0
32 [watchdogd] 0.0 0.0
33 [kworker/0:1H-kblockd] 0.0 0.0
35 [kworker/u256:1-events_unbo 0.0 0.0
61 [kswapd0] 0.0 0.0
154 [kthrotld] 0.0 0.0
155 [irq/24-pciehp] 0.0 0.0
156 [irq/25-pciehp] 0.0 0.0
157 [irq/26-pciehp] 0.0 0.0
158 [irq/27-pciehp] 0.0 0.0
159 [irq/28-pciehp] 0.0 0.0
160 [irq/29-pciehp] 0.0 0.0
161 [irq/30-pciehp] 0.0 0.0
162 [irq/31-pciehp] 0.0 0.0
163 [irq/32-pciehp] 0.0 0.0
164 [irq/33-pciehp] 0.0 0.0
165 [irq/34-pciehp] 0.0 0.0
166 [irq/35-pciehp] 0.0 0.0
167 [irq/36-pciehp] 0.0 0.0
168 [irq/37-pciehp] 0.0 0.0
169 [irq/38-pciehp] 0.0 0.0
170 [irq/39-pciehp] 0.0 0.0
171 [irq/40-pciehp] 0.0 0.0
172 [irq/41-pciehp] 0.0 0.0
173 [irq/42-pciehp] 0.0 0.0
174 [irq/43-pciehp] 0.0 0.0
175 [irq/44-pciehp] 0.0 0.0
176 [irq/45-pciehp] 0.0 0.0
177 [irq/46-pciehp] 0.0 0.0
178 [irq/47-pciehp] 0.0 0.0
179 [irq/48-pciehp] 0.0 0.0
180 [irq/49-pciehp] 0.0 0.0
181 [irq/50-pciehp] 0.0 0.0
182 [irq/51-pciehp] 0.0 0.0
183 [irq/52-pciehp] 0.0 0.0
184 [irq/53-pciehp] 0.0 0.0
185 [irq/54-pciehp] 0.0 0.0
186 [irq/55-pciehp] 0.0 0.0
187 [acpi_thermal_pm] 0.0 0.0
188 [kmpath_rdacd] 0.0 0.0
189 [kaluad] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
191 [kstrp] 0.0 0.0
448 [mpt_poll_0] 0.0 0.0
449 [ata_sff] 0.0 0.0
450 [mpt/0] 0.0 0.0
451 [scsi_eh_0] 0.0 0.0
452 [scsi_tmf_0] 0.0 0.0
453 [scsi_eh_1] 0.0 0.0
454 [scsi_tmf_1] 0.0 0.0
459 [scsi_eh_2] 0.0 0.0
460 [scsi_tmf_2] 0.0 0.0
468 [irq/16-vmwgfx] 0.0 0.0
470 [ttm_swap] 0.0 0.0
471 [card0-crtc0] 0.0 0.0
472 [card0-crtc1] 0.0 0.0
473 [card0-crtc2] 0.0 0.0
474 [card0-crtc3] 0.0 0.0
475 [card0-crtc4] 0.0 0.0
476 [card0-crtc5] 0.0 0.0
477 [card0-crtc6] 0.0 0.0
478 [card0-crtc7] 0.0 0.0
503 [xfsalloc] 0.0 0.0
504 [xfs_mru_cache] 0.0 0.0
505 [xfs-buf/sda2] 0.0 0.0
506 [xfs-conv/sda2] 0.0 0.0
507 [xfs-cil/sda2] 0.0 0.0
508 [xfs-reclaim/sda] 0.0 0.0
509 [xfs-eofblocks/s] 0.0 0.0
510 [xfs-log/sda2] 0.0 0.0
511 [xfsaild/sda2] 0.0 0.0
639 [xfs-buf/sda3] 0.0 0.0
640 [xfs-conv/sda3] 0.0 0.0
641 [xfs-buf/sda1] 0.0 0.0
642 [xfs-cil/sda3] 0.0 0.0
643 [xfs-conv/sda1] 0.0 0.0
644 [xfs-reclaim/sda] 0.0 0.0
645 [xfs-cil/sda1] 0.0 0.0
646 [xfs-eofblocks/s] 0.0 0.0
647 [xfs-reclaim/sda] 0.0 0.0
648 [xfs-log/sda3] 0.0 0.0
649 [xfs-eofblocks/s] 0.0 0.0
650 [xfsaild/sda3] 0.0 0.0
651 [xfs-log/sda1] 0.0 0.0
652 [xfsaild/sda1] 0.0 0.0
779 [kworker/u257:0-hci0] 0.0 0.0
783 [kworker/u257:1-hci0] 0.0 0.0
9556 [kworker/u256:0-events_unbo 0.0 0.0
9993 [kworker/0:3-ata_sff] 0.1 0.0
10152 [kworker/0:0-ata_sff] 0.1 0.0
10171 [kworker/0:1-events] 0.0 0.0
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem k -%cpu |head
PID CMD %CPU %MEM
10164 dd if=/dev/zero of=/dev/nul 99.0 0.1
719 /usr/bin/vmtoolsd 0.1 1.2
9993 [kworker/0:3-events_power_e 0.1 0.0
10152 [kworker/0:0-ata_sff] 0.1 0.0
1 /usr/lib/systemd/systemd -- 0.0 1.4
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
4 [rcu_par_gp] 0.0 0.0
6 [kworker/0:0H-events_highpr 0.0 0.0
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem --sort -%cpu |head
PID CMD %CPU %MEM
10164 dd if=/dev/zero of=/dev/nul 99.2 0.1
719 /usr/bin/vmtoolsd 0.1 1.2
9993 [kworker/0:3-events] 0.1 0.0
10152 [kworker/0:0-ata_sff] 0.1 0.0
1 /usr/lib/systemd/systemd -- 0.0 1.4
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
4 [rcu_par_gp] 0.0 0.0
6 [kworker/0:0H-events_highpr 0.0 0.0
#k 和—sort 一样都是排序
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem,psr --sort -%cpu |head
PID CMD %CPU %MEM PSR
10164 dd if=/dev/zero of=/dev/nul 99.2 0.1 0
719 /usr/bin/vmtoolsd 0.1 1.2 0
9993 [kworker/0:3-events] 0.1 0.0 0
10152 [kworker/0:0-ata_sff] 0.1 0.0 0
1 /usr/lib/systemd/systemd -- 0.0 1.4 0
2 [kthreadd] 0.0 0.0 0
3 [rcu_gp] 0.0 0.0 0
4 [rcu_par_gp] 0.0 0.0 0
6 [kworker/0:0H-events_highpr 0.0 0.0 0
#psr 可以显示运行在哪个CPU
#添加一个cpu内核
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem,psr|grep dd
2 [kthreadd] 0.0 0.0 0
190 [ipv6_addrconf] 0.0 0.0 0
10381 dd if=/dev/zero of=/dev/nul 111 0.1 0
10387 grep --color=auto dd 0.0 0.1 0
[root@rocky8 ~]# ping -f 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem,psr|grep dd
2 [kthreadd] 0.0 0.0 0
190 [ipv6_addrconf] 0.0 0.0 0
10164 dd if=/dev/zero of=/dev/nul 93.0 0.1 1 #现在切换到1号CPU
10213 grep --color=auto dd 0.0 0.1 0
[root@rocky8 ~]# ps auxf |grep bash
root 10189 0.0 0.4 26244 3884 pts/2 Ss 14:35 0:00 | \_ -bash
root 10531 0.0 0.1 12136 1156 pts/2 S+ 14:42 0:00 | \_ grep --color=auto bash
root 10452 0.0 0.4 26244 3976 pts/1 Ss 14:41 0:00 | \_ -bash
root 10484 0.0 0.4 26244 3732 pts/0 Ss 14:41 0:00 \_ -bash
#f 可以显示进程父子关系
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem k -%cpu|head
PID CMD %CPU %MEM
10507 dd if=/dev/zero of=/dev/nul 96.1 0.1
10518 ping -f 127.0.0.1 65.7 0.2
10451 sshd: root@pts/1 3.7 0.8
10216 [kworker/u256:2-events_unbo 0.3 0.0
719 /usr/bin/vmtoolsd 0.1 1.2
9993 [kworker/0:3-events_power_e 0.1 0.0
1 /usr/lib/systemd/systemd -- 0.0 1.4
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem,psr k -%cpu|head
PID CMD %CPU %MEM PSR
10507 dd if=/dev/zero of=/dev/nul 95.6 0.1 0
10518 ping -f 127.0.0.1 65.5 0.2 1
10451 sshd: root@pts/1 3.8 0.8 1
10216 [kworker/u256:2-events_unbo 0.3 0.0 0
719 /usr/bin/vmtoolsd 0.1 1.2 0
9993 [kworker/0:3-ata_sff] 0.1 0.0 0
1 /usr/lib/systemd/systemd -- 0.0 1.4 1
2 [kthreadd] 0.0 0.0 0
3 [rcu_gp] 0.0 0.0 0
范例:查看进程详细信息
[root@rocky8 ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 13:03 ? 00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
root 2 0 0 13:03 ? 00:00:00 [kthreadd]
root 3 2 0 13:03 ? 00:00:00 [rcu_gp]
root 4 2 0 13:03 ? 00:00:00 [rcu_par_gp]
root 6 2 0 13:03 ? 00:00:00 [kworker/0:0H-events_highpri]
root 9 2 0 13:03 ? 00:00:00 [mm_percpu_wq]
root 10 2 0 13:03 ? 00:00:00 [ksoftirqd/0]
root 11 2 0 13:03 ? 00:00:00 [rcu_sched]
root 12 2 0 13:03 ? 00:00:00 [migration/0]
root 13 2 0 13:03 ? 00:00:00 [watchdog/0]
root 14 2 0 13:03 ? 00:00:00 [cpuhp/0]
root 16 2 0 13:03 ? 00:00:00 [kdevtmpfs]
root 17 2 0 13:03 ? 00:00:00 [netns]
root 18 2 0 13:03 ? 00:00:00 [kauditd]
root 19 2 0 13:03 ? 00:00:00 [khungtaskd]
root 20 2 0 13:03 ? 00:00:00 [oom_reaper]
root 21 2 0 13:03 ? 00:00:00 [writeback]
root 22 2 0 13:03 ? 00:00:00 [kcompactd0]
root 23 2 0 13:03 ? 00:00:00 [ksmd]
root 24 2 0 13:03 ? 00:00:00 [khugepaged]
root 25 2 0 13:03 ? 00:00:00 [crypto]
root 26 2 0 13:03 ? 00:00:00 [kintegrityd]
root 27 2 0 13:03 ? 00:00:00 [kblockd]
root 28 2 0 13:03 ? 00:00:00 [blkcg_punt_bio]
root 29 2 0 13:03 ? 00:00:00 [tpm_dev_wq]
root 30 2 0 13:03 ? 00:00:00 [md]
root 31 2 0 13:03 ? 00:00:00 [edac-poller]
root 32 2 0 13:03 ? 00:00:00 [watchdogd]
root 33 2 0 13:03 ? 00:00:00 [kworker/0:1H-kblockd]
root 61 2 0 13:03 ? 00:00:00 [kswapd0]
root 154 2 0 13:03 ? 00:00:00 [kthrotld]
root 155 2 0 13:03 ? 00:00:00 [irq/24-pciehp]
root 156 2 0 13:03 ? 00:00:00 [irq/25-pciehp]
root 157 2 0 13:03 ? 00:00:00 [irq/26-pciehp]
root 158 2 0 13:03 ? 00:00:00 [irq/27-pciehp]
root 159 2 0 13:03 ? 00:00:00 [irq/28-pciehp]
root 160 2 0 13:03 ? 00:00:00 [irq/29-pciehp]
root 161 2 0 13:03 ? 00:00:00 [irq/30-pciehp]
root 162 2 0 13:03 ? 00:00:00 [irq/31-pciehp]
root 163 2 0 13:03 ? 00:00:00 [irq/32-pciehp]
root 164 2 0 13:03 ? 00:00:00 [irq/33-pciehp]
root 165 2 0 13:03 ? 00:00:00 [irq/34-pciehp]
root 166 2 0 13:03 ? 00:00:00 [irq/35-pciehp]
root 167 2 0 13:03 ? 00:00:00 [irq/36-pciehp]
root 168 2 0 13:03 ? 00:00:00 [irq/37-pciehp]
root 169 2 0 13:03 ? 00:00:00 [irq/38-pciehp]
root 170 2 0 13:03 ? 00:00:00 [irq/39-pciehp]
root 171 2 0 13:03 ? 00:00:00 [irq/40-pciehp]
root 172 2 0 13:03 ? 00:00:00 [irq/41-pciehp]
root 173 2 0 13:03 ? 00:00:00 [irq/42-pciehp]
root 174 2 0 13:03 ? 00:00:00 [irq/43-pciehp]
root 175 2 0 13:03 ? 00:00:00 [irq/44-pciehp]
root 176 2 0 13:03 ? 00:00:00 [irq/45-pciehp]
root 177 2 0 13:03 ? 00:00:00 [irq/46-pciehp]
root 178 2 0 13:03 ? 00:00:00 [irq/47-pciehp]
root 179 2 0 13:03 ? 00:00:00 [irq/48-pciehp]
root 180 2 0 13:03 ? 00:00:00 [irq/49-pciehp]
root 181 2 0 13:03 ? 00:00:00 [irq/50-pciehp]
root 182 2 0 13:03 ? 00:00:00 [irq/51-pciehp]
root 183 2 0 13:03 ? 00:00:00 [irq/52-pciehp]
root 184 2 0 13:03 ? 00:00:00 [irq/53-pciehp]
root 185 2 0 13:03 ? 00:00:00 [irq/54-pciehp]
root 186 2 0 13:03 ? 00:00:00 [irq/55-pciehp]
root 187 2 0 13:03 ? 00:00:00 [acpi_thermal_pm]
root 188 2 0 13:03 ? 00:00:00 [kmpath_rdacd]
root 189 2 0 13:03 ? 00:00:00 [kaluad]
root 190 2 0 13:03 ? 00:00:00 [ipv6_addrconf]
root 191 2 0 13:03 ? 00:00:00 [kstrp]
root 448 2 0 13:03 ? 00:00:00 [mpt_poll_0]
root 449 2 0 13:03 ? 00:00:00 [ata_sff]
root 450 2 0 13:03 ? 00:00:00 [mpt/0]
root 451 2 0 13:03 ? 00:00:00 [scsi_eh_0]
root 452 2 0 13:03 ? 00:00:00 [scsi_tmf_0]
root 453 2 0 13:03 ? 00:00:00 [scsi_eh_1]
root 454 2 0 13:03 ? 00:00:00 [scsi_tmf_1]
root 459 2 0 13:03 ? 00:00:00 [scsi_eh_2]
root 460 2 0 13:03 ? 00:00:00 [scsi_tmf_2]
root 468 2 0 13:03 ? 00:00:00 [irq/16-vmwgfx]
root 470 2 0 13:03 ? 00:00:00 [ttm_swap]
root 471 2 0 13:03 ? 00:00:00 [card0-crtc0]
root 472 2 0 13:03 ? 00:00:00 [card0-crtc1]
root 473 2 0 13:03 ? 00:00:00 [card0-crtc2]
root 474 2 0 13:03 ? 00:00:00 [card0-crtc3]
root 475 2 0 13:03 ? 00:00:00 [card0-crtc4]
root 476 2 0 13:03 ? 00:00:00 [card0-crtc5]
root 477 2 0 13:03 ? 00:00:00 [card0-crtc6]
root 478 2 0 13:03 ? 00:00:00 [card0-crtc7]
root 503 2 0 13:03 ? 00:00:00 [xfsalloc]
root 504 2 0 13:03 ? 00:00:00 [xfs_mru_cache]
root 505 2 0 13:03 ? 00:00:00 [xfs-buf/sda2]
root 506 2 0 13:03 ? 00:00:00 [xfs-conv/sda2]
root 507 2 0 13:03 ? 00:00:00 [xfs-cil/sda2]
root 508 2 0 13:03 ? 00:00:00 [xfs-reclaim/sda]
root 509 2 0 13:03 ? 00:00:00 [xfs-eofblocks/s]
root 510 2 0 13:03 ? 00:00:00 [xfs-log/sda2]
root 511 2 0 13:03 ? 00:00:00 [xfsaild/sda2]
root 601 1 0 13:03 ? 00:00:00 /usr/lib/systemd/systemd-journald
root 635 1 0 13:03 ? 00:00:00 /usr/lib/systemd/systemd-udevd
root 639 2 0 13:03 ? 00:00:00 [xfs-buf/sda3]
root 640 2 0 13:03 ? 00:00:00 [xfs-conv/sda3]
root 641 2 0 13:03 ? 00:00:00 [xfs-buf/sda1]
root 642 2 0 13:03 ? 00:00:00 [xfs-cil/sda3]
root 643 2 0 13:03 ? 00:00:00 [xfs-conv/sda1]
root 644 2 0 13:03 ? 00:00:00 [xfs-reclaim/sda]
root 645 2 0 13:03 ? 00:00:00 [xfs-cil/sda1]
root 646 2 0 13:03 ? 00:00:00 [xfs-eofblocks/s]
root 647 2 0 13:03 ? 00:00:00 [xfs-reclaim/sda]
root 648 2 0 13:03 ? 00:00:00 [xfs-log/sda3]
root 649 2 0 13:03 ? 00:00:00 [xfs-eofblocks/s]
root 650 2 0 13:03 ? 00:00:00 [xfsaild/sda3]
root 651 2 0 13:03 ? 00:00:00 [xfs-log/sda1]
root 652 2 0 13:03 ? 00:00:00 [xfsaild/sda1]
root 685 1 0 13:03 ? 00:00:00 /sbin/auditd
root 718 1 0 13:03 ? 00:00:00 /usr/bin/VGAuthService -s
root 719 1 0 13:03 ? 00:00:07 /usr/bin/vmtoolsd
root 721 1 0 13:03 ? 00:00:00 /usr/sbin/sssd -i --logger=files
polkitd 723 1 0 13:03 ? 00:00:00 /usr/lib/polkit-1/polkitd --no-debug
dbus 726 1 0 13:03 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 728 1 0 13:03 ? 00:00:00 /usr/sbin/NetworkManager --no-daemon
root 765 1 0 13:03 ? 00:00:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
root 767 1 0 13:03 ? 00:00:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
root 773 721 0 13:03 ? 00:00:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
root 809 721 0 13:03 ? 00:00:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root 837 1 0 13:03 ? 00:00:00 /usr/sbin/rsyslogd -n
root 838 1 0 13:03 ? 00:00:00 /usr/lib/systemd/systemd-logind
root 843 1 0 13:03 ? 00:00:00 /usr/sbin/crond -n
root 855 1 0 13:03 tty1 00:00:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root 1302 1 0 13:04 ? 00:00:00 /usr/lib/systemd/systemd --user
root 1305 1302 0 13:04 ? 00:00:00 (sd-pam)
root 9556 2 0 14:00 ? 00:00:02 [kworker/u256:0-events_unbound]
root 9993 2 0 14:00 ? 00:00:03 [kworker/0:3-events]
root 10005 1 0 14:01 ? 00:00:00 /usr/sbin/anacron -s
root 10152 2 0 14:27 ? 00:00:00 [kworker/0:0-events_freezable_power_]
root 10186 765 0 14:35 ? 00:00:00 sshd: root [priv]
root 10188 10186 0 14:35 ? 00:00:00 sshd: root@pts/2
root 10189 10188 0 14:35 pts/2 00:00:00 -bash
root 10216 2 0 14:36 ? 00:00:01 [kworker/u256:2-events_unbound]
root 10224 2 0 14:37 ? 00:00:00 [cpuhp/1]
root 10225 2 0 14:37 ? 00:00:00 [watchdog/1]
root 10226 2 0 14:37 ? 00:00:00 [migration/1]
root 10227 2 0 14:37 ? 00:00:00 [ksoftirqd/1]
root 10228 2 0 14:37 ? 00:00:00 [kworker/1:0-mm_percpu_wq]
root 10229 2 0 14:37 ? 00:00:00 [kworker/1:0H-events_highpri]
root 10239 2 0 14:37 ? 00:00:00 [kworker/1:1H-kblockd]
root 10246 2 0 14:37 ? 00:00:00 [kworker/u257:0-hci0]
root 10247 2 0 14:37 ? 00:00:00 [kworker/u257:1-hci0]
root 10347 2 0 14:37 ? 00:00:00 [kworker/1:3-cgroup_destroy]
root 10449 765 0 14:41 ? 00:00:00 sshd: root [priv]
root 10451 10449 4 14:41 ? 00:00:19 sshd: root@pts/1
root 10452 10451 0 14:41 pts/1 00:00:00 -bash
root 10481 765 0 14:41 ? 00:00:00 sshd: root [priv]
root 10483 10481 0 14:41 ? 00:00:00 sshd: root@pts/0
root 10484 10483 0 14:41 pts/0 00:00:00 -bash
root 10507 10484 95 14:41 pts/0 00:05:46 dd if=/dev/zero of=/dev/null
root 10518 10452 65 14:41 pts/1 00:03:50 ping -f 127.0.0.1
root 10536 2 0 14:46 ? 00:00:00 [kworker/0:1-events]
root 10537 10189 0 14:47 pts/2 00:00:00 ps -ef
[root@rocky8 ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 1.4 183736 11408 ? Ss 13:03 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
root 2 0.0 0.0 0 0 ? S 13:03 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 13:03 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 13:03 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 13:03 0:00 [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I< 13:03 0:00 [mm_percpu_wq]
root 10 0.0 0.0 0 0 ? S 13:03 0:00 [ksoftirqd/0]
root 11 0.0 0.0 0 0 ? I 13:03 0:00 [rcu_sched]
root 12 0.0 0.0 0 0 ? S 13:03 0:00 [migration/0]
root 13 0.0 0.0 0 0 ? S 13:03 0:00 [watchdog/0]
root 14 0.0 0.0 0 0 ? S 13:03 0:00 [cpuhp/0]
root 16 0.0 0.0 0 0 ? S 13:03 0:00 [kdevtmpfs]
root 17 0.0 0.0 0 0 ? I< 13:03 0:00 [netns]
root 18 0.0 0.0 0 0 ? S 13:03 0:00 [kauditd]
root 19 0.0 0.0 0 0 ? S 13:03 0:00 [khungtaskd]
root 20 0.0 0.0 0 0 ? S 13:03 0:00 [oom_reaper]
root 21 0.0 0.0 0 0 ? I< 13:03 0:00 [writeback]
root 22 0.0 0.0 0 0 ? S 13:03 0:00 [kcompactd0]
root 23 0.0 0.0 0 0 ? SN 13:03 0:00 [ksmd]
root 24 0.0 0.0 0 0 ? SN 13:03 0:00 [khugepaged]
root 25 0.0 0.0 0 0 ? I< 13:03 0:00 [crypto]
root 26 0.0 0.0 0 0 ? I< 13:03 0:00 [kintegrityd]
root 27 0.0 0.0 0 0 ? I< 13:03 0:00 [kblockd]
root 28 0.0 0.0 0 0 ? I< 13:03 0:00 [blkcg_punt_bio]
root 29 0.0 0.0 0 0 ? I< 13:03 0:00 [tpm_dev_wq]
root 30 0.0 0.0 0 0 ? I< 13:03 0:00 [md]
root 31 0.0 0.0 0 0 ? I< 13:03 0:00 [edac-poller]
root 32 0.0 0.0 0 0 ? S 13:03 0:00 [watchdogd]
root 33 0.0 0.0 0 0 ? I< 13:03 0:00 [kworker/0:1H-kblockd]
root 61 0.0 0.0 0 0 ? S 13:03 0:00 [kswapd0]
root 154 0.0 0.0 0 0 ? I< 13:03 0:00 [kthrotld]
root 155 0.0 0.0 0 0 ? S 13:03 0:00 [irq/24-pciehp]
root 156 0.0 0.0 0 0 ? S 13:03 0:00 [irq/25-pciehp]
root 157 0.0 0.0 0 0 ? S 13:03 0:00 [irq/26-pciehp]
root 158 0.0 0.0 0 0 ? S 13:03 0:00 [irq/27-pciehp]
root 159 0.0 0.0 0 0 ? S 13:03 0:00 [irq/28-pciehp]
root 160 0.0 0.0 0 0 ? S 13:03 0:00 [irq/29-pciehp]
root 161 0.0 0.0 0 0 ? S 13:03 0:00 [irq/30-pciehp]
root 162 0.0 0.0 0 0 ? S 13:03 0:00 [irq/31-pciehp]
root 163 0.0 0.0 0 0 ? S 13:03 0:00 [irq/32-pciehp]
root 164 0.0 0.0 0 0 ? S 13:03 0:00 [irq/33-pciehp]
root 165 0.0 0.0 0 0 ? S 13:03 0:00 [irq/34-pciehp]
root 166 0.0 0.0 0 0 ? S 13:03 0:00 [irq/35-pciehp]
root 167 0.0 0.0 0 0 ? S 13:03 0:00 [irq/36-pciehp]
root 168 0.0 0.0 0 0 ? S 13:03 0:00 [irq/37-pciehp]
root 169 0.0 0.0 0 0 ? S 13:03 0:00 [irq/38-pciehp]
root 170 0.0 0.0 0 0 ? S 13:03 0:00 [irq/39-pciehp]
root 171 0.0 0.0 0 0 ? S 13:03 0:00 [irq/40-pciehp]
root 172 0.0 0.0 0 0 ? S 13:03 0:00 [irq/41-pciehp]
root 173 0.0 0.0 0 0 ? S 13:03 0:00 [irq/42-pciehp]
root 174 0.0 0.0 0 0 ? S 13:03 0:00 [irq/43-pciehp]
root 175 0.0 0.0 0 0 ? S 13:03 0:00 [irq/44-pciehp]
root 176 0.0 0.0 0 0 ? S 13:03 0:00 [irq/45-pciehp]
root 177 0.0 0.0 0 0 ? S 13:03 0:00 [irq/46-pciehp]
root 178 0.0 0.0 0 0 ? S 13:03 0:00 [irq/47-pciehp]
root 179 0.0 0.0 0 0 ? S 13:03 0:00 [irq/48-pciehp]
root 180 0.0 0.0 0 0 ? S 13:03 0:00 [irq/49-pciehp]
root 181 0.0 0.0 0 0 ? S 13:03 0:00 [irq/50-pciehp]
root 182 0.0 0.0 0 0 ? S 13:03 0:00 [irq/51-pciehp]
root 183 0.0 0.0 0 0 ? S 13:03 0:00 [irq/52-pciehp]
root 184 0.0 0.0 0 0 ? S 13:03 0:00 [irq/53-pciehp]
root 185 0.0 0.0 0 0 ? S 13:03 0:00 [irq/54-pciehp]
root 186 0.0 0.0 0 0 ? S 13:03 0:00 [irq/55-pciehp]
root 187 0.0 0.0 0 0 ? I< 13:03 0:00 [acpi_thermal_pm]
root 188 0.0 0.0 0 0 ? I< 13:03 0:00 [kmpath_rdacd]
root 189 0.0 0.0 0 0 ? I< 13:03 0:00 [kaluad]
root 190 0.0 0.0 0 0 ? I< 13:03 0:00 [ipv6_addrconf]
root 191 0.0 0.0 0 0 ? I< 13:03 0:00 [kstrp]
root 448 0.0 0.0 0 0 ? I< 13:03 0:00 [mpt_poll_0]
root 449 0.0 0.0 0 0 ? I< 13:03 0:00 [ata_sff]
root 450 0.0 0.0 0 0 ? I< 13:03 0:00 [mpt/0]
root 451 0.0 0.0 0 0 ? S 13:03 0:00 [scsi_eh_0]
root 452 0.0 0.0 0 0 ? I< 13:03 0:00 [scsi_tmf_0]
root 453 0.0 0.0 0 0 ? S 13:03 0:00 [scsi_eh_1]
root 454 0.0 0.0 0 0 ? I< 13:03 0:00 [scsi_tmf_1]
root 459 0.0 0.0 0 0 ? S 13:03 0:00 [scsi_eh_2]
root 460 0.0 0.0 0 0 ? I< 13:03 0:00 [scsi_tmf_2]
root 468 0.0 0.0 0 0 ? S 13:03 0:00 [irq/16-vmwgfx]
root 470 0.0 0.0 0 0 ? I< 13:03 0:00 [ttm_swap]
root 471 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc0]
root 472 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc1]
root 473 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc2]
root 474 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc3]
root 475 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc4]
root 476 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc5]
root 477 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc6]
root 478 0.0 0.0 0 0 ? S 13:03 0:00 [card0-crtc7]
root 503 0.0 0.0 0 0 ? I< 13:03 0:00 [xfsalloc]
root 504 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs_mru_cache]
root 505 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-buf/sda2]
root 506 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-conv/sda2]
root 507 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-cil/sda2]
root 508 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-reclaim/sda]
root 509 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-eofblocks/s]
root 510 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-log/sda2]
root 511 0.0 0.0 0 0 ? S 13:03 0:00 [xfsaild/sda2]
root 601 0.0 1.1 97728 9320 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-journald
root 635 0.0 1.2 124580 10004 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-udevd
root 639 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-buf/sda3]
root 640 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-conv/sda3]
root 641 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-buf/sda1]
root 642 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-cil/sda3]
root 643 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-conv/sda1]
root 644 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-reclaim/sda]
root 645 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-cil/sda1]
root 646 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-eofblocks/s]
root 647 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-reclaim/sda]
root 648 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-log/sda3]
root 649 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-eofblocks/s]
root 650 0.0 0.0 0 0 ? S 13:03 0:00 [xfsaild/sda3]
root 651 0.0 0.0 0 0 ? I< 13:03 0:00 [xfs-log/sda1]
root 652 0.0 0.0 0 0 ? S 13:03 0:00 [xfsaild/sda1]
root 685 0.0 0.3 67960 2656 ? S<sl 13:03 0:00 /sbin/auditd
root 718 0.0 1.4 86200 11416 ? Ss 13:03 0:00 /usr/bin/VGAuthService -s
root 719 0.1 1.2 278328 10044 ? Ssl 13:03 0:07 /usr/bin/vmtoolsd
root 721 0.0 1.7 216924 14320 ? Ss 13:03 0:00 /usr/sbin/sssd -i --logger=files
polkitd 723 0.0 3.0 1630348 24108 ? Ssl 13:03 0:00 /usr/lib/polkit-1/polkitd --no-debug
dbus 726 0.0 0.6 76628 5504 ? Ss 13:03 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --syst
root 728 0.0 2.2 391536 18224 ? Ssl 13:03 0:00 /usr/sbin/NetworkManager --no-daemon
root 765 0.0 1.0 94444 8036 ? Ss 13:03 0:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh
root 767 0.0 3.7 414624 30244 ? Ssl 13:03 0:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
root 773 0.0 1.8 225680 15080 ? S 13:03 0:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=f
root 809 0.0 5.1 226992 40968 ? S 13:03 0:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root 837 0.0 0.6 215336 5328 ? Ssl 13:03 0:00 /usr/sbin/rsyslogd -n
root 838 0.0 1.0 103976 8212 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-logind
root 843 0.0 0.4 36956 3604 ? Ss 13:03 0:00 /usr/sbin/crond -n
root 855 0.0 0.2 13656 1724 tty1 Ss+ 13:03 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root 1302 0.0 1.2 100692 9904 ? Ss 13:04 0:00 /usr/lib/systemd/systemd --user
root 1305 0.0 0.3 238892 2588 ? S 13:04 0:00 (sd-pam)
root 9556 0.0 0.0 0 0 ? R 14:00 0:02 [kworker/u256:0-events_unbound]
root 9993 0.1 0.0 0 0 ? I 14:00 0:03 [kworker/0:3-ata_sff]
root 10005 0.0 0.3 36020 2844 ? Ss 14:01 0:00 /usr/sbin/anacron -s
root 10152 0.0 0.0 0 0 ? I 14:27 0:00 [kworker/0:0-events_freezable_power_]
root 10186 0.0 1.0 139184 8668 ? Ss 14:35 0:00 sshd: root [priv]
root 10188 0.0 0.8 153404 7084 ? S 14:35 0:00 sshd: root@pts/2
root 10189 0.0 0.4 26244 3884 pts/2 Ss 14:35 0:00 -bash
root 10216 0.2 0.0 0 0 ? I 14:36 0:01 [kworker/u256:2-events_unbound]
root 10224 0.0 0.0 0 0 ? S 14:37 0:00 [cpuhp/1]
root 10225 0.0 0.0 0 0 ? S 14:37 0:00 [watchdog/1]
root 10226 0.0 0.0 0 0 ? S 14:37 0:00 [migration/1]
root 10227 0.0 0.0 0 0 ? S 14:37 0:00 [ksoftirqd/1]
root 10228 0.0 0.0 0 0 ? I 14:37 0:00 [kworker/1:0-events]
root 10229 0.0 0.0 0 0 ? I< 14:37 0:00 [kworker/1:0H-events_highpri]
root 10239 0.0 0.0 0 0 ? I< 14:37 0:00 [kworker/1:1H-kblockd]
root 10246 0.0 0.0 0 0 ? I< 14:37 0:00 [kworker/u257:0-hci0]
root 10247 0.0 0.0 0 0 ? I< 14:37 0:00 [kworker/u257:1-hci0]
root 10347 0.0 0.0 0 0 ? I 14:37 0:00 [kworker/1:3-cgroup_destroy]
root 10449 0.0 1.0 139184 8808 ? Ss 14:41 0:00 sshd: root [priv]
root 10451 4.9 0.8 153404 7068 ? S 14:41 0:19 sshd: root@pts/1
root 10452 0.0 0.4 26244 3976 pts/1 Ss 14:41 0:00 -bash
root 10481 0.0 1.0 139184 8740 ? Ss 14:41 0:00 sshd: root [priv]
root 10483 0.0 0.8 153404 7032 ? S 14:41 0:00 sshd: root@pts/0
root 10484 0.0 0.4 26244 3732 pts/0 Ss 14:41 0:00 -bash
root 10507 95.3 0.1 7352 980 pts/0 R+ 14:41 5:50 dd if=/dev/zero of=/dev/null
root 10518 65.2 0.2 32448 2252 pts/1 R+ 14:41 3:52 ping -f 127.0.0.1
root 10536 0.0 0.0 0 0 ? I 14:46 0:00 [kworker/0:1-events]
root 10538 0.0 0.4 58728 4000 pts/2 R+ 14:47 0:00 ps aux
范例:
#查看进程的父子关系
[root@rocky8 ~]# ps auxf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S 13:03 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kworker/0:0H-events_highpri]
root 9 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [mm_percpu_wq]
root 10 0.0 0.0 0 0 ? S 13:03 0:00 \_ [ksoftirqd/0]
root 11 0.0 0.0 0 0 ? I 13:03 0:00 \_ [rcu_sched]
root 12 0.0 0.0 0 0 ? S 13:03 0:00 \_ [migration/0]
root 13 0.0 0.0 0 0 ? S 13:03 0:00 \_ [watchdog/0]
root 14 0.0 0.0 0 0 ? S 13:03 0:00 \_ [cpuhp/0]
root 16 0.0 0.0 0 0 ? S 13:03 0:00 \_ [kdevtmpfs]
root 17 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [netns]
root 18 0.0 0.0 0 0 ? S 13:03 0:00 \_ [kauditd]
root 19 0.0 0.0 0 0 ? S 13:03 0:00 \_ [khungtaskd]
root 20 0.0 0.0 0 0 ? S 13:03 0:00 \_ [oom_reaper]
root 21 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [writeback]
root 22 0.0 0.0 0 0 ? S 13:03 0:00 \_ [kcompactd0]
root 23 0.0 0.0 0 0 ? SN 13:03 0:00 \_ [ksmd]
root 24 0.0 0.0 0 0 ? SN 13:03 0:00 \_ [khugepaged]
root 25 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [crypto]
root 26 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kintegrityd]
root 27 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kblockd]
root 28 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [blkcg_punt_bio]
root 29 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [tpm_dev_wq]
root 30 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [md]
root 31 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [edac-poller]
root 32 0.0 0.0 0 0 ? S 13:03 0:00 \_ [watchdogd]
root 33 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kworker/0:1H-kblockd]
root 61 0.0 0.0 0 0 ? S 13:03 0:00 \_ [kswapd0]
root 154 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kthrotld]
root 155 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/24-pciehp]
root 156 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/25-pciehp]
root 157 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/26-pciehp]
root 158 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/27-pciehp]
root 159 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/28-pciehp]
root 160 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/29-pciehp]
root 161 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/30-pciehp]
root 162 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/31-pciehp]
root 163 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/32-pciehp]
root 164 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/33-pciehp]
root 165 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/34-pciehp]
root 166 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/35-pciehp]
root 167 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/36-pciehp]
root 168 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/37-pciehp]
root 169 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/38-pciehp]
root 170 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/39-pciehp]
root 171 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/40-pciehp]
root 172 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/41-pciehp]
root 173 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/42-pciehp]
root 174 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/43-pciehp]
root 175 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/44-pciehp]
root 176 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/45-pciehp]
root 177 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/46-pciehp]
root 178 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/47-pciehp]
root 179 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/48-pciehp]
root 180 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/49-pciehp]
root 181 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/50-pciehp]
root 182 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/51-pciehp]
root 183 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/52-pciehp]
root 184 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/53-pciehp]
root 185 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/54-pciehp]
root 186 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/55-pciehp]
root 187 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [acpi_thermal_pm]
root 188 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kmpath_rdacd]
root 189 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kaluad]
root 190 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [ipv6_addrconf]
root 191 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [kstrp]
root 448 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [mpt_poll_0]
root 449 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [ata_sff]
root 450 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [mpt/0]
root 451 0.0 0.0 0 0 ? S 13:03 0:00 \_ [scsi_eh_0]
root 452 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [scsi_tmf_0]
root 453 0.0 0.0 0 0 ? S 13:03 0:00 \_ [scsi_eh_1]
root 454 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [scsi_tmf_1]
root 459 0.0 0.0 0 0 ? S 13:03 0:00 \_ [scsi_eh_2]
root 460 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [scsi_tmf_2]
root 468 0.0 0.0 0 0 ? S 13:03 0:00 \_ [irq/16-vmwgfx]
root 470 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [ttm_swap]
root 471 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc0]
root 472 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc1]
root 473 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc2]
root 474 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc3]
root 475 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc4]
root 476 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc5]
root 477 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc6]
root 478 0.0 0.0 0 0 ? S 13:03 0:00 \_ [card0-crtc7]
root 503 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfsalloc]
root 504 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs_mru_cache]
root 505 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-buf/sda2]
root 506 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-conv/sda2]
root 507 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-cil/sda2]
root 508 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-reclaim/sda]
root 509 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-eofblocks/s]
root 510 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-log/sda2]
root 511 0.0 0.0 0 0 ? S 13:03 0:00 \_ [xfsaild/sda2]
root 639 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-buf/sda3]
root 640 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-conv/sda3]
root 641 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-buf/sda1]
root 642 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-cil/sda3]
root 643 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-conv/sda1]
root 644 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-reclaim/sda]
root 645 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-cil/sda1]
root 646 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-eofblocks/s]
root 647 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-reclaim/sda]
root 648 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-log/sda3]
root 649 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-eofblocks/s]
root 650 0.0 0.0 0 0 ? S 13:03 0:00 \_ [xfsaild/sda3]
root 651 0.0 0.0 0 0 ? I< 13:03 0:00 \_ [xfs-log/sda1]
root 652 0.0 0.0 0 0 ? S 13:03 0:00 \_ [xfsaild/sda1]
root 9556 0.0 0.0 0 0 ? R 14:00 0:02 \_ [kworker/u256:0-events_unbound]
root 9993 0.1 0.0 0 0 ? I 14:00 0:03 \_ [kworker/0:3-events]
root 10152 0.0 0.0 0 0 ? I 14:27 0:00 \_ [kworker/0:0-events_freezable_power_]
root 10216 0.2 0.0 0 0 ? I 14:36 0:01 \_ [kworker/u256:2-events_unbound]
root 10224 0.0 0.0 0 0 ? S 14:37 0:00 \_ [cpuhp/1]
root 10225 0.0 0.0 0 0 ? S 14:37 0:00 \_ [watchdog/1]
root 10226 0.0 0.0 0 0 ? S 14:37 0:00 \_ [migration/1]
root 10227 0.0 0.0 0 0 ? S 14:37 0:00 \_ [ksoftirqd/1]
root 10228 0.0 0.0 0 0 ? I 14:37 0:00 \_ [kworker/1:0-events]
root 10229 0.0 0.0 0 0 ? I< 14:37 0:00 \_ [kworker/1:0H-events_highpri]
root 10239 0.0 0.0 0 0 ? I< 14:37 0:00 \_ [kworker/1:1H-kblockd]
root 10246 0.0 0.0 0 0 ? I< 14:37 0:00 \_ [kworker/u257:0-hci0]
root 10247 0.0 0.0 0 0 ? I< 14:37 0:00 \_ [kworker/u257:1-hci0]
root 10347 0.0 0.0 0 0 ? I 14:37 0:00 \_ [kworker/1:3-cgroup_destroy]
root 10536 0.0 0.0 0 0 ? I 14:46 0:00 \_ [kworker/0:1-ata_sff]
root 10539 0.2 0.0 0 0 ? R 14:47 0:00 \_ [kworker/u256:1-events_unbound]
root 1 0.0 1.4 183736 11408 ? Ss 13:03 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
root 601 0.0 1.1 97728 9320 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-journald
root 635 0.0 1.2 124580 10004 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-udevd
root 685 0.0 0.3 67960 2656 ? S<sl 13:03 0:00 /sbin/auditd
root 718 0.0 1.4 86200 11416 ? Ss 13:03 0:00 /usr/bin/VGAuthService -s
root 719 0.1 1.2 278328 10044 ? Ssl 13:03 0:07 /usr/bin/vmtoolsd
root 721 0.0 1.7 216924 14320 ? Ss 13:03 0:00 /usr/sbin/sssd -i --logger=files
root 773 0.0 1.8 225680 15080 ? S 13:03 0:00 \_ /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logg
root 809 0.0 5.1 226992 40968 ? S 13:03 0:00 \_ /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
polkitd 723 0.0 3.0 1630348 24108 ? Ssl 13:03 0:00 /usr/lib/polkit-1/polkitd --no-debug
dbus 726 0.0 0.6 76628 5504 ? Ss 13:03 0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --syst
root 728 0.0 2.2 391536 18224 ? Ssl 13:03 0:00 /usr/sbin/NetworkManager --no-daemon
root 765 0.0 1.0 94444 8036 ? Ss 13:03 0:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh
root 10186 0.0 1.0 139184 8668 ? Ss 14:35 0:00 \_ sshd: root [priv]
root 10188 0.0 0.8 153404 7084 ? S 14:35 0:00 | \_ sshd: root@pts/2
root 10189 0.0 0.4 26244 3884 pts/2 Ss 14:35 0:00 | \_ -bash
root 10540 0.0 0.4 58892 3952 pts/2 R+ 14:48 0:00 | \_ ps auxf
root 10449 0.0 1.0 139184 8808 ? Ss 14:41 0:00 \_ sshd: root [priv]
root 10451 5.0 0.8 153404 7068 ? R 14:41 0:22 | \_ sshd: root@pts/1
root 10452 0.0 0.4 26244 3976 pts/1 Ss 14:41 0:00 | \_ -bash
root 10518 65.3 0.2 32448 2252 pts/1 R+ 14:41 4:27 | \_ ping -f 127.0.0.1
root 10481 0.0 1.0 139184 8740 ? Ss 14:41 0:00 \_ sshd: root [priv]
root 10483 0.0 0.8 153404 7032 ? S 14:41 0:00 \_ sshd: root@pts/0
root 10484 0.0 0.4 26244 3732 pts/0 Ss 14:41 0:00 \_ -bash
root 10507 95.3 0.1 7352 980 pts/0 R+ 14:41 6:40 \_ dd if=/dev/zero of=/dev/null
root 767 0.0 3.7 414624 30244 ? Ssl 13:03 0:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
root 837 0.0 0.6 215336 5328 ? Ssl 13:03 0:00 /usr/sbin/rsyslogd -n
root 838 0.0 1.0 103976 8212 ? Ss 13:03 0:00 /usr/lib/systemd/systemd-logind
root 843 0.0 0.4 36956 3604 ? Ss 13:03 0:00 /usr/sbin/crond -n
root 855 0.0 0.2 13656 1724 tty1 Ss+ 13:03 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root 1302 0.0 1.2 100692 9904 ? Ss 13:04 0:00 /usr/lib/systemd/systemd --user
root 1305 0.0 0.3 238892 2588 ? S 13:04 0:00 \_ (sd-pam)
root 10005 0.0 0.3 36020 2844 ? Ss 14:01 0:00 /usr/sbin/anacron -s
#查看进程的特定属性
[root@rocky8 ~]# ps axo pid,cmd,%mem,%cpu
PID CMD %MEM %CPU
1 /usr/lib/systemd/systemd -- 1.4 0.0
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
4 [rcu_par_gp] 0.0 0.0
6 [kworker/0:0H-events_highpr 0.0 0.0
9 [mm_percpu_wq] 0.0 0.0
10 [ksoftirqd/0] 0.0 0.0
11 [rcu_sched] 0.0 0.0
12 [migration/0] 0.0 0.0
13 [watchdog/0] 0.0 0.0
14 [cpuhp/0] 0.0 0.0
16 [kdevtmpfs] 0.0 0.0
17 [netns] 0.0 0.0
18 [kauditd] 0.0 0.0
19 [khungtaskd] 0.0 0.0
20 [oom_reaper] 0.0 0.0
21 [writeback] 0.0 0.0
22 [kcompactd0] 0.0 0.0
23 [ksmd] 0.0 0.0
24 [khugepaged] 0.0 0.0
25 [crypto] 0.0 0.0
26 [kintegrityd] 0.0 0.0
27 [kblockd] 0.0 0.0
28 [blkcg_punt_bio] 0.0 0.0
29 [tpm_dev_wq] 0.0 0.0
30 [md] 0.0 0.0
31 [edac-poller] 0.0 0.0
32 [watchdogd] 0.0 0.0
33 [kworker/0:1H-xfs-log/sda2] 0.0 0.0
61 [kswapd0] 0.0 0.0
154 [kthrotld] 0.0 0.0
155 [irq/24-pciehp] 0.0 0.0
156 [irq/25-pciehp] 0.0 0.0
157 [irq/26-pciehp] 0.0 0.0
158 [irq/27-pciehp] 0.0 0.0
159 [irq/28-pciehp] 0.0 0.0
160 [irq/29-pciehp] 0.0 0.0
161 [irq/30-pciehp] 0.0 0.0
162 [irq/31-pciehp] 0.0 0.0
163 [irq/32-pciehp] 0.0 0.0
164 [irq/33-pciehp] 0.0 0.0
165 [irq/34-pciehp] 0.0 0.0
166 [irq/35-pciehp] 0.0 0.0
167 [irq/36-pciehp] 0.0 0.0
168 [irq/37-pciehp] 0.0 0.0
169 [irq/38-pciehp] 0.0 0.0
170 [irq/39-pciehp] 0.0 0.0
171 [irq/40-pciehp] 0.0 0.0
172 [irq/41-pciehp] 0.0 0.0
173 [irq/42-pciehp] 0.0 0.0
174 [irq/43-pciehp] 0.0 0.0
175 [irq/44-pciehp] 0.0 0.0
176 [irq/45-pciehp] 0.0 0.0
177 [irq/46-pciehp] 0.0 0.0
178 [irq/47-pciehp] 0.0 0.0
179 [irq/48-pciehp] 0.0 0.0
180 [irq/49-pciehp] 0.0 0.0
181 [irq/50-pciehp] 0.0 0.0
182 [irq/51-pciehp] 0.0 0.0
183 [irq/52-pciehp] 0.0 0.0
184 [irq/53-pciehp] 0.0 0.0
185 [irq/54-pciehp] 0.0 0.0
186 [irq/55-pciehp] 0.0 0.0
187 [acpi_thermal_pm] 0.0 0.0
188 [kmpath_rdacd] 0.0 0.0
189 [kaluad] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
191 [kstrp] 0.0 0.0
448 [mpt_poll_0] 0.0 0.0
449 [ata_sff] 0.0 0.0
450 [mpt/0] 0.0 0.0
451 [scsi_eh_0] 0.0 0.0
452 [scsi_tmf_0] 0.0 0.0
453 [scsi_eh_1] 0.0 0.0
454 [scsi_tmf_1] 0.0 0.0
459 [scsi_eh_2] 0.0 0.0
460 [scsi_tmf_2] 0.0 0.0
468 [irq/16-vmwgfx] 0.0 0.0
470 [ttm_swap] 0.0 0.0
471 [card0-crtc0] 0.0 0.0
472 [card0-crtc1] 0.0 0.0
473 [card0-crtc2] 0.0 0.0
474 [card0-crtc3] 0.0 0.0
475 [card0-crtc4] 0.0 0.0
476 [card0-crtc5] 0.0 0.0
477 [card0-crtc6] 0.0 0.0
478 [card0-crtc7] 0.0 0.0
503 [xfsalloc] 0.0 0.0
504 [xfs_mru_cache] 0.0 0.0
505 [xfs-buf/sda2] 0.0 0.0
506 [xfs-conv/sda2] 0.0 0.0
507 [xfs-cil/sda2] 0.0 0.0
508 [xfs-reclaim/sda] 0.0 0.0
509 [xfs-eofblocks/s] 0.0 0.0
510 [xfs-log/sda2] 0.0 0.0
511 [xfsaild/sda2] 0.0 0.0
601 /usr/lib/systemd/systemd-jo 1.1 0.0
635 /usr/lib/systemd/systemd-ud 1.2 0.0
639 [xfs-buf/sda3] 0.0 0.0
640 [xfs-conv/sda3] 0.0 0.0
641 [xfs-buf/sda1] 0.0 0.0
642 [xfs-cil/sda3] 0.0 0.0
643 [xfs-conv/sda1] 0.0 0.0
644 [xfs-reclaim/sda] 0.0 0.0
645 [xfs-cil/sda1] 0.0 0.0
646 [xfs-eofblocks/s] 0.0 0.0
647 [xfs-reclaim/sda] 0.0 0.0
648 [xfs-log/sda3] 0.0 0.0
649 [xfs-eofblocks/s] 0.0 0.0
650 [xfsaild/sda3] 0.0 0.0
651 [xfs-log/sda1] 0.0 0.0
652 [xfsaild/sda1] 0.0 0.0
685 /sbin/auditd 0.3 0.0
718 /usr/bin/VGAuthService -s 1.4 0.0
719 /usr/bin/vmtoolsd 1.2 0.1
721 /usr/sbin/sssd -i --logger= 1.7 0.0
723 /usr/lib/polkit-1/polkitd - 3.0 0.0
726 /usr/bin/dbus-daemon --syst 0.6 0.0
728 /usr/sbin/NetworkManager -- 2.2 0.0
765 /usr/sbin/sshd -D -oCiphers 1.0 0.0
767 /usr/libexec/platform-pytho 3.7 0.0
773 /usr/libexec/sssd/sssd_be - 1.8 0.0
809 /usr/libexec/sssd/sssd_nss 5.1 0.0
837 /usr/sbin/rsyslogd -n 0.6 0.0
838 /usr/lib/systemd/systemd-lo 1.0 0.0
843 /usr/sbin/crond -n 0.4 0.0
855 /sbin/agetty -o -p -- \u -- 0.2 0.0
1302 /usr/lib/systemd/systemd -- 1.2 0.0
1305 (sd-pam) 0.3 0.0
9556 [kworker/u256:0-events_unbo 0.0 0.0
9993 [kworker/0:3-ata_sff] 0.0 0.1
10005 /usr/sbin/anacron -s 0.3 0.0
10152 [kworker/0:0-events_freezab 0.0 0.0
10186 sshd: root [priv] 1.0 0.0
10188 sshd: root@pts/2 0.8 0.0
10189 -bash 0.4 0.0
10216 [kworker/u256:2-events_unbo 0.0 0.2
10224 [cpuhp/1] 0.0 0.0
10225 [watchdog/1] 0.0 0.0
10226 [migration/1] 0.0 0.0
10227 [ksoftirqd/1] 0.0 0.0
10228 [kworker/1:0-mm_percpu_wq] 0.0 0.0
10229 [kworker/1:0H-events_highpr 0.0 0.0
10239 [kworker/1:1H-kblockd] 0.0 0.0
10246 [kworker/u257:0-hci0] 0.0 0.0
10247 [kworker/u257:1-hci0] 0.0 0.0
10347 [kworker/1:3-cgroup_destroy 0.0 0.0
10449 sshd: root [priv] 1.0 0.0
10451 sshd: root@pts/1 0.8 5.0
10452 -bash 0.4 0.0
10481 sshd: root [priv] 1.0 0.0
10483 sshd: root@pts/0 0.8 0.0
10484 -bash 0.4 0.0
10507 dd if=/dev/zero of=/dev/nul 0.1 95.4
10518 ping -f 127.0.0.1 0.2 65.2
10536 [kworker/0:1-events] 0.0 0.0
10539 [kworker/u256:1-events_unbo 0.0 0.1
10541 ps axo pid,cmd,%mem,%cpu 0.2 0.0
范例:针对属性排序,CentOS6 以下版本不支持
#按CPU利用率倒序排序
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem k -%cpu
PID CMD %CPU %MEM
10507 dd if=/dev/zero of=/dev/nul 95.5 0.1
10518 ping -f 127.0.0.1 65.1 0.2
10451 sshd: root@pts/1 4.9 0.8
10216 [kworker/u256:2-events_unbo 0.2 0.0
719 /usr/bin/vmtoolsd 0.1 1.2
9993 [kworker/0:3-mpt_poll_0] 0.1 0.0
10539 [kworker/u256:1-events_unbo 0.1 0.0
1 /usr/lib/systemd/systemd -- 0.0 1.4
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
4 [rcu_par_gp] 0.0 0.0
6 [kworker/0:0H-events_highpr 0.0 0.0
9 [mm_percpu_wq] 0.0 0.0
10 [ksoftirqd/0] 0.0 0.0
11 [rcu_sched] 0.0 0.0
12 [migration/0] 0.0 0.0
13 [watchdog/0] 0.0 0.0
14 [cpuhp/0] 0.0 0.0
16 [kdevtmpfs] 0.0 0.0
17 [netns] 0.0 0.0
18 [kauditd] 0.0 0.0
19 [khungtaskd] 0.0 0.0
20 [oom_reaper] 0.0 0.0
21 [writeback] 0.0 0.0
22 [kcompactd0] 0.0 0.0
23 [ksmd] 0.0 0.0
24 [khugepaged] 0.0 0.0
25 [crypto] 0.0 0.0
26 [kintegrityd] 0.0 0.0
27 [kblockd] 0.0 0.0
28 [blkcg_punt_bio] 0.0 0.0
29 [tpm_dev_wq] 0.0 0.0
30 [md] 0.0 0.0
31 [edac-poller] 0.0 0.0
32 [watchdogd] 0.0 0.0
33 [kworker/0:1H-kblockd] 0.0 0.0
61 [kswapd0] 0.0 0.0
154 [kthrotld] 0.0 0.0
155 [irq/24-pciehp] 0.0 0.0
156 [irq/25-pciehp] 0.0 0.0
157 [irq/26-pciehp] 0.0 0.0
158 [irq/27-pciehp] 0.0 0.0
159 [irq/28-pciehp] 0.0 0.0
160 [irq/29-pciehp] 0.0 0.0
161 [irq/30-pciehp] 0.0 0.0
162 [irq/31-pciehp] 0.0 0.0
163 [irq/32-pciehp] 0.0 0.0
164 [irq/33-pciehp] 0.0 0.0
165 [irq/34-pciehp] 0.0 0.0
166 [irq/35-pciehp] 0.0 0.0
167 [irq/36-pciehp] 0.0 0.0
168 [irq/37-pciehp] 0.0 0.0
169 [irq/38-pciehp] 0.0 0.0
170 [irq/39-pciehp] 0.0 0.0
171 [irq/40-pciehp] 0.0 0.0
172 [irq/41-pciehp] 0.0 0.0
173 [irq/42-pciehp] 0.0 0.0
174 [irq/43-pciehp] 0.0 0.0
175 [irq/44-pciehp] 0.0 0.0
176 [irq/45-pciehp] 0.0 0.0
177 [irq/46-pciehp] 0.0 0.0
178 [irq/47-pciehp] 0.0 0.0
179 [irq/48-pciehp] 0.0 0.0
180 [irq/49-pciehp] 0.0 0.0
181 [irq/50-pciehp] 0.0 0.0
182 [irq/51-pciehp] 0.0 0.0
183 [irq/52-pciehp] 0.0 0.0
184 [irq/53-pciehp] 0.0 0.0
185 [irq/54-pciehp] 0.0 0.0
186 [irq/55-pciehp] 0.0 0.0
187 [acpi_thermal_pm] 0.0 0.0
188 [kmpath_rdacd] 0.0 0.0
189 [kaluad] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
191 [kstrp] 0.0 0.0
448 [mpt_poll_0] 0.0 0.0
449 [ata_sff] 0.0 0.0
450 [mpt/0] 0.0 0.0
451 [scsi_eh_0] 0.0 0.0
452 [scsi_tmf_0] 0.0 0.0
453 [scsi_eh_1] 0.0 0.0
454 [scsi_tmf_1] 0.0 0.0
459 [scsi_eh_2] 0.0 0.0
460 [scsi_tmf_2] 0.0 0.0
468 [irq/16-vmwgfx] 0.0 0.0
470 [ttm_swap] 0.0 0.0
471 [card0-crtc0] 0.0 0.0
472 [card0-crtc1] 0.0 0.0
473 [card0-crtc2] 0.0 0.0
474 [card0-crtc3] 0.0 0.0
475 [card0-crtc4] 0.0 0.0
476 [card0-crtc5] 0.0 0.0
477 [card0-crtc6] 0.0 0.0
478 [card0-crtc7] 0.0 0.0
503 [xfsalloc] 0.0 0.0
504 [xfs_mru_cache] 0.0 0.0
505 [xfs-buf/sda2] 0.0 0.0
506 [xfs-conv/sda2] 0.0 0.0
507 [xfs-cil/sda2] 0.0 0.0
508 [xfs-reclaim/sda] 0.0 0.0
509 [xfs-eofblocks/s] 0.0 0.0
510 [xfs-log/sda2] 0.0 0.0
511 [xfsaild/sda2] 0.0 0.0
601 /usr/lib/systemd/systemd-jo 0.0 1.1
635 /usr/lib/systemd/systemd-ud 0.0 1.2
639 [xfs-buf/sda3] 0.0 0.0
640 [xfs-conv/sda3] 0.0 0.0
641 [xfs-buf/sda1] 0.0 0.0
642 [xfs-cil/sda3] 0.0 0.0
643 [xfs-conv/sda1] 0.0 0.0
644 [xfs-reclaim/sda] 0.0 0.0
645 [xfs-cil/sda1] 0.0 0.0
646 [xfs-eofblocks/s] 0.0 0.0
647 [xfs-reclaim/sda] 0.0 0.0
648 [xfs-log/sda3] 0.0 0.0
649 [xfs-eofblocks/s] 0.0 0.0
650 [xfsaild/sda3] 0.0 0.0
651 [xfs-log/sda1] 0.0 0.0
652 [xfsaild/sda1] 0.0 0.0
685 /sbin/auditd 0.0 0.3
718 /usr/bin/VGAuthService -s 0.0 1.4
721 /usr/sbin/sssd -i --logger= 0.0 1.7
723 /usr/lib/polkit-1/polkitd - 0.0 3.0
726 /usr/bin/dbus-daemon --syst 0.0 0.6
728 /usr/sbin/NetworkManager -- 0.0 2.2
765 /usr/sbin/sshd -D -oCiphers 0.0 1.0
767 /usr/libexec/platform-pytho 0.0 3.7
773 /usr/libexec/sssd/sssd_be - 0.0 1.8
809 /usr/libexec/sssd/sssd_nss 0.0 5.1
837 /usr/sbin/rsyslogd -n 0.0 0.6
838 /usr/lib/systemd/systemd-lo 0.0 1.0
843 /usr/sbin/crond -n 0.0 0.4
855 /sbin/agetty -o -p -- \u -- 0.0 0.2
1302 /usr/lib/systemd/systemd -- 0.0 1.2
1305 (sd-pam) 0.0 0.3
9556 [kworker/u256:0-events_unbo 0.0 0.0
10005 /usr/sbin/anacron -s 0.0 0.3
10152 [kworker/0:0-events_freezab 0.0 0.0
10186 sshd: root [priv] 0.0 1.0
10188 sshd: root@pts/2 0.0 0.8
10189 -bash 0.0 0.4
10224 [cpuhp/1] 0.0 0.0
10225 [watchdog/1] 0.0 0.0
10226 [migration/1] 0.0 0.0
10227 [ksoftirqd/1] 0.0 0.0
10228 [kworker/1:0-mm_percpu_wq] 0.0 0.0
10229 [kworker/1:0H-events_highpr 0.0 0.0
10239 [kworker/1:1H-kblockd] 0.0 0.0
10246 [kworker/u257:0-hci0] 0.0 0.0
10247 [kworker/u257:1-hci0] 0.0 0.0
10347 [kworker/1:3-cgroup_destroy 0.0 0.0
10449 sshd: root [priv] 0.0 1.0
10452 -bash 0.0 0.4
10481 sshd: root [priv] 0.0 1.0
10483 sshd: root@pts/0 0.0 0.8
10484 -bash 0.0 0.4
10536 [kworker/0:1-ata_sff] 0.0 0.0
10542 ps axo pid,cmd,%cpu,%mem k 0.0 0.4
#按内存倒序排序
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem --sort -%mem
PID CMD %CPU %MEM
809 /usr/libexec/sssd/sssd_nss 0.0 5.1
767 /usr/libexec/platform-pytho 0.0 3.7
723 /usr/lib/polkit-1/polkitd - 0.0 3.0
728 /usr/sbin/NetworkManager -- 0.0 2.2
773 /usr/libexec/sssd/sssd_be - 0.0 1.8
721 /usr/sbin/sssd -i --logger= 0.0 1.7
718 /usr/bin/VGAuthService -s 0.0 1.4
1 /usr/lib/systemd/systemd -- 0.0 1.4
719 /usr/bin/vmtoolsd 0.1 1.2
635 /usr/lib/systemd/systemd-ud 0.0 1.2
1302 /usr/lib/systemd/systemd -- 0.0 1.2
601 /usr/lib/systemd/systemd-jo 0.0 1.1
10449 sshd: root [priv] 0.0 1.0
10481 sshd: root [priv] 0.0 1.0
10186 sshd: root [priv] 0.0 1.0
838 /usr/lib/systemd/systemd-lo 0.0 1.0
765 /usr/sbin/sshd -D -oCiphers 0.0 1.0
10188 sshd: root@pts/2 0.0 0.8
10451 sshd: root@pts/1 4.9 0.8
10483 sshd: root@pts/0 0.0 0.8
726 /usr/bin/dbus-daemon --syst 0.0 0.6
837 /usr/sbin/rsyslogd -n 0.0 0.6
10452 -bash 0.0 0.4
10189 -bash 0.0 0.4
10484 -bash 0.0 0.4
843 /usr/sbin/crond -n 0.0 0.4
10543 ps axo pid,cmd,%cpu,%mem -- 0.0 0.4
10005 /usr/sbin/anacron -s 0.0 0.3
685 /sbin/auditd 0.0 0.3
1305 (sd-pam) 0.0 0.3
10518 ping -f 127.0.0.1 65.0 0.2
855 /sbin/agetty -o -p -- \u -- 0.0 0.2
10507 dd if=/dev/zero of=/dev/nul 95.5 0.1
2 [kthreadd] 0.0 0.0
3 [rcu_gp] 0.0 0.0
4 [rcu_par_gp] 0.0 0.0
6 [kworker/0:0H-events_highpr 0.0 0.0
9 [mm_percpu_wq] 0.0 0.0
10 [ksoftirqd/0] 0.0 0.0
11 [rcu_sched] 0.0 0.0
12 [migration/0] 0.0 0.0
13 [watchdog/0] 0.0 0.0
14 [cpuhp/0] 0.0 0.0
16 [kdevtmpfs] 0.0 0.0
17 [netns] 0.0 0.0
18 [kauditd] 0.0 0.0
19 [khungtaskd] 0.0 0.0
20 [oom_reaper] 0.0 0.0
21 [writeback] 0.0 0.0
22 [kcompactd0] 0.0 0.0
23 [ksmd] 0.0 0.0
24 [khugepaged] 0.0 0.0
25 [crypto] 0.0 0.0
26 [kintegrityd] 0.0 0.0
27 [kblockd] 0.0 0.0
28 [blkcg_punt_bio] 0.0 0.0
29 [tpm_dev_wq] 0.0 0.0
30 [md] 0.0 0.0
31 [edac-poller] 0.0 0.0
32 [watchdogd] 0.0 0.0
33 [kworker/0:1H-kblockd] 0.0 0.0
61 [kswapd0] 0.0 0.0
154 [kthrotld] 0.0 0.0
155 [irq/24-pciehp] 0.0 0.0
156 [irq/25-pciehp] 0.0 0.0
157 [irq/26-pciehp] 0.0 0.0
158 [irq/27-pciehp] 0.0 0.0
159 [irq/28-pciehp] 0.0 0.0
160 [irq/29-pciehp] 0.0 0.0
161 [irq/30-pciehp] 0.0 0.0
162 [irq/31-pciehp] 0.0 0.0
163 [irq/32-pciehp] 0.0 0.0
164 [irq/33-pciehp] 0.0 0.0
165 [irq/34-pciehp] 0.0 0.0
166 [irq/35-pciehp] 0.0 0.0
167 [irq/36-pciehp] 0.0 0.0
168 [irq/37-pciehp] 0.0 0.0
169 [irq/38-pciehp] 0.0 0.0
170 [irq/39-pciehp] 0.0 0.0
171 [irq/40-pciehp] 0.0 0.0
172 [irq/41-pciehp] 0.0 0.0
173 [irq/42-pciehp] 0.0 0.0
174 [irq/43-pciehp] 0.0 0.0
175 [irq/44-pciehp] 0.0 0.0
176 [irq/45-pciehp] 0.0 0.0
177 [irq/46-pciehp] 0.0 0.0
178 [irq/47-pciehp] 0.0 0.0
179 [irq/48-pciehp] 0.0 0.0
180 [irq/49-pciehp] 0.0 0.0
181 [irq/50-pciehp] 0.0 0.0
182 [irq/51-pciehp] 0.0 0.0
183 [irq/52-pciehp] 0.0 0.0
184 [irq/53-pciehp] 0.0 0.0
185 [irq/54-pciehp] 0.0 0.0
186 [irq/55-pciehp] 0.0 0.0
187 [acpi_thermal_pm] 0.0 0.0
188 [kmpath_rdacd] 0.0 0.0
189 [kaluad] 0.0 0.0
190 [ipv6_addrconf] 0.0 0.0
191 [kstrp] 0.0 0.0
448 [mpt_poll_0] 0.0 0.0
449 [ata_sff] 0.0 0.0
450 [mpt/0] 0.0 0.0
451 [scsi_eh_0] 0.0 0.0
452 [scsi_tmf_0] 0.0 0.0
453 [scsi_eh_1] 0.0 0.0
454 [scsi_tmf_1] 0.0 0.0
459 [scsi_eh_2] 0.0 0.0
460 [scsi_tmf_2] 0.0 0.0
468 [irq/16-vmwgfx] 0.0 0.0
470 [ttm_swap] 0.0 0.0
471 [card0-crtc0] 0.0 0.0
472 [card0-crtc1] 0.0 0.0
473 [card0-crtc2] 0.0 0.0
474 [card0-crtc3] 0.0 0.0
475 [card0-crtc4] 0.0 0.0
476 [card0-crtc5] 0.0 0.0
477 [card0-crtc6] 0.0 0.0
478 [card0-crtc7] 0.0 0.0
503 [xfsalloc] 0.0 0.0
504 [xfs_mru_cache] 0.0 0.0
505 [xfs-buf/sda2] 0.0 0.0
506 [xfs-conv/sda2] 0.0 0.0
507 [xfs-cil/sda2] 0.0 0.0
508 [xfs-reclaim/sda] 0.0 0.0
509 [xfs-eofblocks/s] 0.0 0.0
510 [xfs-log/sda2] 0.0 0.0
511 [xfsaild/sda2] 0.0 0.0
639 [xfs-buf/sda3] 0.0 0.0
640 [xfs-conv/sda3] 0.0 0.0
641 [xfs-buf/sda1] 0.0 0.0
642 [xfs-cil/sda3] 0.0 0.0
643 [xfs-conv/sda1] 0.0 0.0
644 [xfs-reclaim/sda] 0.0 0.0
645 [xfs-cil/sda1] 0.0 0.0
646 [xfs-eofblocks/s] 0.0 0.0
647 [xfs-reclaim/sda] 0.0 0.0
648 [xfs-log/sda3] 0.0 0.0
649 [xfs-eofblocks/s] 0.0 0.0
650 [xfsaild/sda3] 0.0 0.0
651 [xfs-log/sda1] 0.0 0.0
652 [xfsaild/sda1] 0.0 0.0
9556 [kworker/u256:0-events_unbo 0.0 0.0
9993 [kworker/0:3-events] 0.1 0.0
10152 [kworker/0:0-events_freezab 0.0 0.0
10216 [kworker/u256:2-events_unbo 0.2 0.0
10224 [cpuhp/1] 0.0 0.0
10225 [watchdog/1] 0.0 0.0
10226 [migration/1] 0.0 0.0
10227 [ksoftirqd/1] 0.0 0.0
10228 [kworker/1:0-xfs-buf/sda2] 0.0 0.0
10229 [kworker/1:0H-events_highpr 0.0 0.0
10239 [kworker/1:1H-kblockd] 0.0 0.0
10246 [kworker/u257:0-hci0] 0.0 0.0
10247 [kworker/u257:1-hci0] 0.0 0.0
10347 [kworker/1:3-cgroup_destroy 0.0 0.0
10536 [kworker/0:1-ata_sff] 0.0 0.0
10539 [kworker/u256:1-events_unbo 0.1 0.0
范例:有效用户和实际用户
[root@rocky8 ~]# su - raymond
Last login: Sun Oct 31 14:16:01 CST 2021 on pts/1
[raymond@rocky8 ~]$ passwd
Changing password for user raymond.
Current password:
[root@rocky8 ~]# ps axo pid,cmd,%cpu,%mem,user,euser,ruser | grep passwd
10581 passwd 0.0 1.0 root root raymond
10583 grep --color=auto passwd 0.0 0.1 root root root
范例:
#查询你拥有的所有进程
[root@rocky8 ~]# ps -x
PID TTY STAT TIME COMMAND
1 ? Ss 0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
2 ? S 0:00 [kthreadd]
3 ? I< 0:00 [rcu_gp]
4 ? I< 0:00 [rcu_par_gp]
6 ? I< 0:00 [kworker/0:0H-events_highpri]
9 ? I< 0:00 [mm_percpu_wq]
10 ? S 0:00 [ksoftirqd/0]
11 ? I 0:00 [rcu_sched]
12 ? S 0:00 [migration/0]
13 ? S 0:00 [watchdog/0]
14 ? S 0:00 [cpuhp/0]
16 ? S 0:00 [kdevtmpfs]
17 ? I< 0:00 [netns]
18 ? S 0:00 [kauditd]
19 ? S 0:00 [khungtaskd]
20 ? S 0:00 [oom_reaper]
21 ? I< 0:00 [writeback]
22 ? S 0:00 [kcompactd0]
23 ? SN 0:00 [ksmd]
24 ? SN 0:00 [khugepaged]
25 ? I< 0:00 [crypto]
26 ? I< 0:00 [kintegrityd]
27 ? I< 0:00 [kblockd]
28 ? I< 0:00 [blkcg_punt_bio]
29 ? I< 0:00 [tpm_dev_wq]
30 ? I< 0:00 [md]
31 ? I< 0:00 [edac-poller]
32 ? S 0:00 [watchdogd]
33 ? I< 0:00 [kworker/0:1H-kblockd]
61 ? S 0:00 [kswapd0]
154 ? I< 0:00 [kthrotld]
155 ? S 0:00 [irq/24-pciehp]
156 ? S 0:00 [irq/25-pciehp]
157 ? S 0:00 [irq/26-pciehp]
158 ? S 0:00 [irq/27-pciehp]
159 ? S 0:00 [irq/28-pciehp]
160 ? S 0:00 [irq/29-pciehp]
161 ? S 0:00 [irq/30-pciehp]
162 ? S 0:00 [irq/31-pciehp]
163 ? S 0:00 [irq/32-pciehp]
164 ? S 0:00 [irq/33-pciehp]
165 ? S 0:00 [irq/34-pciehp]
166 ? S 0:00 [irq/35-pciehp]
167 ? S 0:00 [irq/36-pciehp]
168 ? S 0:00 [irq/37-pciehp]
169 ? S 0:00 [irq/38-pciehp]
170 ? S 0:00 [irq/39-pciehp]
171 ? S 0:00 [irq/40-pciehp]
172 ? S 0:00 [irq/41-pciehp]
173 ? S 0:00 [irq/42-pciehp]
174 ? S 0:00 [irq/43-pciehp]
175 ? S 0:00 [irq/44-pciehp]
176 ? S 0:00 [irq/45-pciehp]
177 ? S 0:00 [irq/46-pciehp]
178 ? S 0:00 [irq/47-pciehp]
179 ? S 0:00 [irq/48-pciehp]
180 ? S 0:00 [irq/49-pciehp]
181 ? S 0:00 [irq/50-pciehp]
182 ? S 0:00 [irq/51-pciehp]
183 ? S 0:00 [irq/52-pciehp]
184 ? S 0:00 [irq/53-pciehp]
185 ? S 0:00 [irq/54-pciehp]
186 ? S 0:00 [irq/55-pciehp]
187 ? I< 0:00 [acpi_thermal_pm]
188 ? I< 0:00 [kmpath_rdacd]
189 ? I< 0:00 [kaluad]
190 ? I< 0:00 [ipv6_addrconf]
191 ? I< 0:00 [kstrp]
448 ? I< 0:00 [mpt_poll_0]
449 ? I< 0:00 [ata_sff]
450 ? I< 0:00 [mpt/0]
451 ? S 0:00 [scsi_eh_0]
452 ? I< 0:00 [scsi_tmf_0]
453 ? S 0:00 [scsi_eh_1]
454 ? I< 0:00 [scsi_tmf_1]
459 ? S 0:00 [scsi_eh_2]
460 ? I< 0:00 [scsi_tmf_2]
468 ? S 0:00 [irq/16-vmwgfx]
470 ? I< 0:00 [ttm_swap]
471 ? S 0:00 [card0-crtc0]
472 ? S 0:00 [card0-crtc1]
473 ? S 0:00 [card0-crtc2]
474 ? S 0:00 [card0-crtc3]
475 ? S 0:00 [card0-crtc4]
476 ? S 0:00 [card0-crtc5]
477 ? S 0:00 [card0-crtc6]
478 ? S 0:00 [card0-crtc7]
503 ? I< 0:00 [xfsalloc]
504 ? I< 0:00 [xfs_mru_cache]
505 ? I< 0:00 [xfs-buf/sda2]
506 ? I< 0:00 [xfs-conv/sda2]
507 ? I< 0:00 [xfs-cil/sda2]
508 ? I< 0:00 [xfs-reclaim/sda]
509 ? I< 0:00 [xfs-eofblocks/s]
510 ? I< 0:00 [xfs-log/sda2]
511 ? S 0:00 [xfsaild/sda2]
601 ? Ss 0:00 /usr/lib/systemd/systemd-journald
635 ? Ss 0:00 /usr/lib/systemd/systemd-udevd
639 ? I< 0:00 [xfs-buf/sda3]
640 ? I< 0:00 [xfs-conv/sda3]
641 ? I< 0:00 [xfs-buf/sda1]
642 ? I< 0:00 [xfs-cil/sda3]
643 ? I< 0:00 [xfs-conv/sda1]
644 ? I< 0:00 [xfs-reclaim/sda]
645 ? I< 0:00 [xfs-cil/sda1]
646 ? I< 0:00 [xfs-eofblocks/s]
647 ? I< 0:00 [xfs-reclaim/sda]
648 ? I< 0:00 [xfs-log/sda3]
649 ? I< 0:00 [xfs-eofblocks/s]
650 ? S 0:00 [xfsaild/sda3]
651 ? I< 0:00 [xfs-log/sda1]
652 ? S 0:00 [xfsaild/sda1]
685 ? S<sl 0:00 /sbin/auditd
718 ? Ss 0:00 /usr/bin/VGAuthService -s
719 ? Ssl 0:07 /usr/bin/vmtoolsd
721 ? Ss 0:00 /usr/sbin/sssd -i --logger=files
728 ? Ssl 0:00 /usr/sbin/NetworkManager --no-daemon
765 ? Ss 0:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@
767 ? Ssl 0:01 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
773 ? S 0:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
809 ? S 0:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
837 ? Ssl 0:00 /usr/sbin/rsyslogd -n
838 ? Ss 0:00 /usr/lib/systemd/systemd-logind
843 ? Ss 0:00 /usr/sbin/crond -n
855 tty1 Ss+ 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
1302 ? Ss 0:00 /usr/lib/systemd/systemd --user
1305 ? S 0:00 (sd-pam)
9556 ? R 0:02 [kworker/u256:0-events_unbound]
9993 ? I 0:03 [kworker/0:3-ata_sff]
10005 ? Ss 0:00 /usr/sbin/anacron -s
10152 ? I 0:00 [kworker/0:0-ata_sff]
10186 ? Ss 0:00 sshd: root [priv]
10188 ? S 0:00 sshd: root@pts/2
10189 pts/2 Ss 0:00 -bash
10216 ? I 0:01 [kworker/u256:2-events_unbound]
10224 ? S 0:00 [cpuhp/1]
10225 ? S 0:00 [watchdog/1]
10226 ? S 0:00 [migration/1]
10227 ? S 0:00 [ksoftirqd/1]
10228 ? I 0:00 [kworker/1:0-mm_percpu_wq]
10229 ? I< 0:00 [kworker/1:0H-events_highpri]
10239 ? I< 0:00 [kworker/1:1H-kblockd]
10246 ? I< 0:00 [kworker/u257:0-hci0]
10247 ? I< 0:00 [kworker/u257:1-hci0]
10347 ? I 0:00 [kworker/1:3-cgroup_destroy]
10449 ? Ss 0:00 sshd: root [priv]
10451 ? S 0:30 sshd: root@pts/1
10452 pts/1 Ss 0:00 -bash
10481 ? Ss 0:00 sshd: root [priv]
10483 ? S 0:00 sshd: root@pts/0
10484 pts/0 Ss 0:00 -bash
10507 pts/0 R+ 10:58 dd if=/dev/zero of=/dev/null
10536 ? I 0:00 [kworker/0:1-events_freezable_power_]
10539 ? I 0:00 [kworker/u256:1-events_unbound]
10544 ? I 0:00 [kworker/0:2-mpt_poll_0]
10549 pts/2 S 0:00 su - raymond
10581 pts/2 S+ 0:00 passwd
10584 pts/1 R+ 0:00 ps -x
#显示指定用户名(RUID)或用户ID的进程
[root@rocky8 ~]# ps -fU raymond
UID PID PPID C STIME TTY TIME CMD
raymond 10550 10549 0 14:51 pts/2 00:00:00 -bash
root 10581 10550 0 14:52 pts/2 00:00:00 passwd
[root@rocky8 ~]# ps -fU 1000
UID PID PPID C STIME TTY TIME CMD
raymond 10550 10549 0 14:51 pts/2 00:00:00 -bash
root 10581 10550 0 14:52 pts/2 00:00:00 passwd
#显示指定用户名(EUID)或用户ID的进程
[root@rocky8 ~]# ps -fu raymond
UID PID PPID C STIME TTY TIME CMD
raymond 10550 10549 0 14:51 pts/2 00:00:00 -bash
[root@rocky8 ~]# ps -fu 1000
UID PID PPID C STIME TTY TIME CMD
raymond 10550 10549 0 14:51 pts/2 00:00:00 -bash
#查看以root用户权限(实际和有效ID)运行的每个进程
[root@rocky8 ~]# ps -U root -u root
PID TTY TIME CMD
1 ? 00:00:01 systemd
2 ? 00:00:00 kthreadd
3 ? 00:00:00 rcu_gp
4 ? 00:00:00 rcu_par_gp
6 ? 00:00:00 kworker/0:0H-events_highpri
9 ? 00:00:00 mm_percpu_wq
10 ? 00:00:00 ksoftirqd/0
11 ? 00:00:00 rcu_sched
12 ? 00:00:00 migration/0
13 ? 00:00:00 watchdog/0
14 ? 00:00:00 cpuhp/0
16 ? 00:00:00 kdevtmpfs
17 ? 00:00:00 netns
18 ? 00:00:00 kauditd
19 ? 00:00:00 khungtaskd
20 ? 00:00:00 oom_reaper
21 ? 00:00:00 writeback
22 ? 00:00:00 kcompactd0
23 ? 00:00:00 ksmd
24 ? 00:00:00 khugepaged
25 ? 00:00:00 crypto
26 ? 00:00:00 kintegrityd
27 ? 00:00:00 kblockd
28 ? 00:00:00 blkcg_punt_bio
29 ? 00:00:00 tpm_dev_wq
30 ? 00:00:00 md
31 ? 00:00:00 edac-poller
32 ? 00:00:00 watchdogd
33 ? 00:00:00 kworker/0:1H-kblockd
61 ? 00:00:00 kswapd0
154 ? 00:00:00 kthrotld
155 ? 00:00:00 irq/24-pciehp
156 ? 00:00:00 irq/25-pciehp
157 ? 00:00:00 irq/26-pciehp
158 ? 00:00:00 irq/27-pciehp
159 ? 00:00:00 irq/28-pciehp
160 ? 00:00:00 irq/29-pciehp
161 ? 00:00:00 irq/30-pciehp
162 ? 00:00:00 irq/31-pciehp
163 ? 00:00:00 irq/32-pciehp
164 ? 00:00:00 irq/33-pciehp
165 ? 00:00:00 irq/34-pciehp
166 ? 00:00:00 irq/35-pciehp
167 ? 00:00:00 irq/36-pciehp
168 ? 00:00:00 irq/37-pciehp
169 ? 00:00:00 irq/38-pciehp
170 ? 00:00:00 irq/39-pciehp
171 ? 00:00:00 irq/40-pciehp
172 ? 00:00:00 irq/41-pciehp
173 ? 00:00:00 irq/42-pciehp
174 ? 00:00:00 irq/43-pciehp
175 ? 00:00:00 irq/44-pciehp
176 ? 00:00:00 irq/45-pciehp
177 ? 00:00:00 irq/46-pciehp
178 ? 00:00:00 irq/47-pciehp
179 ? 00:00:00 irq/48-pciehp
180 ? 00:00:00 irq/49-pciehp
181 ? 00:00:00 irq/50-pciehp
182 ? 00:00:00 irq/51-pciehp
183 ? 00:00:00 irq/52-pciehp
184 ? 00:00:00 irq/53-pciehp
185 ? 00:00:00 irq/54-pciehp
186 ? 00:00:00 irq/55-pciehp
187 ? 00:00:00 acpi_thermal_pm
188 ? 00:00:00 kmpath_rdacd
189 ? 00:00:00 kaluad
190 ? 00:00:00 ipv6_addrconf
191 ? 00:00:00 kstrp
448 ? 00:00:00 mpt_poll_0
449 ? 00:00:00 ata_sff
450 ? 00:00:00 mpt/0
451 ? 00:00:00 scsi_eh_0
452 ? 00:00:00 scsi_tmf_0
453 ? 00:00:00 scsi_eh_1
454 ? 00:00:00 scsi_tmf_1
459 ? 00:00:00 scsi_eh_2
460 ? 00:00:00 scsi_tmf_2
468 ? 00:00:00 irq/16-vmwgfx
470 ? 00:00:00 ttm_swap
471 ? 00:00:00 card0-crtc0
472 ? 00:00:00 card0-crtc1
473 ? 00:00:00 card0-crtc2
474 ? 00:00:00 card0-crtc3
475 ? 00:00:00 card0-crtc4
476 ? 00:00:00 card0-crtc5
477 ? 00:00:00 card0-crtc6
478 ? 00:00:00 card0-crtc7
503 ? 00:00:00 xfsalloc
504 ? 00:00:00 xfs_mru_cache
505 ? 00:00:00 xfs-buf/sda2
506 ? 00:00:00 xfs-conv/sda2
507 ? 00:00:00 xfs-cil/sda2
508 ? 00:00:00 xfs-reclaim/sda
509 ? 00:00:00 xfs-eofblocks/s
510 ? 00:00:00 xfs-log/sda2
511 ? 00:00:00 xfsaild/sda2
601 ? 00:00:00 systemd-journal
635 ? 00:00:00 systemd-udevd
639 ? 00:00:00 xfs-buf/sda3
640 ? 00:00:00 xfs-conv/sda3
641 ? 00:00:00 xfs-buf/sda1
642 ? 00:00:00 xfs-cil/sda3
643 ? 00:00:00 xfs-conv/sda1
644 ? 00:00:00 xfs-reclaim/sda
645 ? 00:00:00 xfs-cil/sda1
646 ? 00:00:00 xfs-eofblocks/s
647 ? 00:00:00 xfs-reclaim/sda
648 ? 00:00:00 xfs-log/sda3
649 ? 00:00:00 xfs-eofblocks/s
650 ? 00:00:00 xfsaild/sda3
651 ? 00:00:00 xfs-log/sda1
652 ? 00:00:00 xfsaild/sda1
685 ? 00:00:00 auditd
718 ? 00:00:00 VGAuthService
719 ? 00:00:07 vmtoolsd
721 ? 00:00:00 sssd
728 ? 00:00:00 NetworkManager
765 ? 00:00:00 sshd
767 ? 00:00:01 tuned
773 ? 00:00:00 sssd_be
809 ? 00:00:00 sssd_nss
837 ? 00:00:00 rsyslogd
838 ? 00:00:00 systemd-logind
843 ? 00:00:00 crond
855 tty1 00:00:00 agetty
1302 ? 00:00:00 systemd
1305 ? 00:00:00 (sd-pam)
9556 ? 00:00:02 kworker/u256:0-events_unbound
10005 ? 00:00:00 anacron
10152 ? 00:00:00 kworker/0:0-events
10186 ? 00:00:00 sshd
10188 ? 00:00:00 sshd
10189 pts/2 00:00:00 bash
10224 ? 00:00:00 cpuhp/1
10225 ? 00:00:00 watchdog/1
10226 ? 00:00:00 migration/1
10227 ? 00:00:00 ksoftirqd/1
10228 ? 00:00:00 kworker/1:0-events
10229 ? 00:00:00 kworker/1:0H-events_highpri
10239 ? 00:00:00 kworker/1:1H-kblockd
10246 ? 00:00:00 kworker/u257:0-hci0
10247 ? 00:00:00 kworker/u257:1-hci0
10347 ? 00:00:00 kworker/1:3-cgroup_destroy
10449 ? 00:00:00 sshd
10451 ? 00:00:30 sshd
10452 pts/1 00:00:00 bash
10481 ? 00:00:00 sshd
10483 ? 00:00:00 sshd
10484 pts/0 00:00:00 bash
10507 pts/0 00:14:10 dd
10536 ? 00:00:00 kworker/0:1-ata_sff
10539 ? 00:00:00 kworker/u256:1-events_unbound
10544 ? 00:00:00 kworker/0:2-ata_sff
10549 pts/2 00:00:00 su
10581 pts/2 00:00:00 passwd
10593 pts/1 00:00:00 ps
#列出某个组拥有的所有进程(实际组ID:RGID或名称)
[root@rocky8 ~]# ps -fG raymond
UID PID PPID C STIME TTY TIME CMD
raymond 10550 10549 0 14:51 pts/2 00:00:00 -bash
root 10581 10550 0 14:52 pts/2 00:00:00 passwd
#列出有效组名称(或会话)所拥有的所有进程
[root@rocky8 ~]# ps -fg raymond
UID PID PPID C STIME TTY TIME CMD
raymond 10550 10549 0 14:51 pts/2 00:00:00 -bash
root 10581 10550 0 14:52 pts/2 00:00:00 passwd
[root@rocky8 ~]# ps -fg 1000
UID PID PPID C STIME TTY TIME CMD
#显示指定的进程ID对应的进程
[root@rocky8 ~]# echo $BASHPID
10452
[root@rocky8 ~]# ps -fp 10452
UID PID PPID C STIME TTY TIME CMD
root 10452 10451 0 14:41 pts/1 00:00:00 -bash
#以父进程ID来显示其下所有的进程,如显示父进程为1234的所有进程
[root@rocky8 ~]# ps -f --ppid 10451
UID PID PPID C STIME TTY TIME CMD
root 10452 10451 0 14:41 pts/1 00:00:00 -bash
#显示指定PID的多个进程
[root@rocky8 ~]# pstree -p|grep bash
|-sshd(765)-+-sshd(10186)---sshd(10188)---bash(10189)---su(10549)---bash(10550)---passwd(10581)
| |-sshd(10449)---sshd(10451)---bash(10452)-+-grep(10609)
| `-sshd(10481)---sshd(10483)---bash(10484)---dd(10507)
[root@rocky8 ~]# ps -fp 10189 10452 10484
UID PID PPID C STIME TTY STAT TIME CMD
root 10189 10188 0 14:35 pts/2 Ss 0:00 -bash
root 10452 10451 0 14:41 pts/1 Ss 0:00 -bash
root 10484 10483 0 14:41 pts/0 Ss 0:00 -bash
#要按tty显示所属进程
[root@rocky8 ~]# ps -ft pts/0
UID PID PPID C STIME TTY TIME CMD
root 10484 10483 0 14:41 pts/0 00:00:00 -bash
root 10507 10484 97 14:41 pts/0 00:19:14 dd if=/dev/zero of=/dev/null
#以进程树显示系统中的进程如何相互链接
[root@rocky8 ~]# ps -e --forest
PID TTY TIME CMD
2 ? 00:00:00 kthreadd
3 ? 00:00:00 \_ rcu_gp
4 ? 00:00:00 \_ rcu_par_gp
6 ? 00:00:00 \_ kworker/0:0H-events_highpri
9 ? 00:00:00 \_ mm_percpu_wq
10 ? 00:00:00 \_ ksoftirqd/0
11 ? 00:00:00 \_ rcu_sched
12 ? 00:00:00 \_ migration/0
13 ? 00:00:00 \_ watchdog/0
14 ? 00:00:00 \_ cpuhp/0
16 ? 00:00:00 \_ kdevtmpfs
17 ? 00:00:00 \_ netns
18 ? 00:00:00 \_ kauditd
19 ? 00:00:00 \_ khungtaskd
20 ? 00:00:00 \_ oom_reaper
21 ? 00:00:00 \_ writeback
22 ? 00:00:00 \_ kcompactd0
23 ? 00:00:00 \_ ksmd
24 ? 00:00:00 \_ khugepaged
25 ? 00:00:00 \_ crypto
26 ? 00:00:00 \_ kintegrityd
27 ? 00:00:00 \_ kblockd
28 ? 00:00:00 \_ blkcg_punt_bio
29 ? 00:00:00 \_ tpm_dev_wq
30 ? 00:00:00 \_ md
31 ? 00:00:00 \_ edac-poller
32 ? 00:00:00 \_ watchdogd
33 ? 00:00:00 \_ kworker/0:1H-kblockd
61 ? 00:00:00 \_ kswapd0
154 ? 00:00:00 \_ kthrotld
155 ? 00:00:00 \_ irq/24-pciehp
156 ? 00:00:00 \_ irq/25-pciehp
157 ? 00:00:00 \_ irq/26-pciehp
158 ? 00:00:00 \_ irq/27-pciehp
159 ? 00:00:00 \_ irq/28-pciehp
160 ? 00:00:00 \_ irq/29-pciehp
161 ? 00:00:00 \_ irq/30-pciehp
162 ? 00:00:00 \_ irq/31-pciehp
163 ? 00:00:00 \_ irq/32-pciehp
164 ? 00:00:00 \_ irq/33-pciehp
165 ? 00:00:00 \_ irq/34-pciehp
166 ? 00:00:00 \_ irq/35-pciehp
167 ? 00:00:00 \_ irq/36-pciehp
168 ? 00:00:00 \_ irq/37-pciehp
169 ? 00:00:00 \_ irq/38-pciehp
170 ? 00:00:00 \_ irq/39-pciehp
171 ? 00:00:00 \_ irq/40-pciehp
172 ? 00:00:00 \_ irq/41-pciehp
173 ? 00:00:00 \_ irq/42-pciehp
174 ? 00:00:00 \_ irq/43-pciehp
175 ? 00:00:00 \_ irq/44-pciehp
176 ? 00:00:00 \_ irq/45-pciehp
177 ? 00:00:00 \_ irq/46-pciehp
178 ? 00:00:00 \_ irq/47-pciehp
179 ? 00:00:00 \_ irq/48-pciehp
180 ? 00:00:00 \_ irq/49-pciehp
181 ? 00:00:00 \_ irq/50-pciehp
182 ? 00:00:00 \_ irq/51-pciehp
183 ? 00:00:00 \_ irq/52-pciehp
184 ? 00:00:00 \_ irq/53-pciehp
185 ? 00:00:00 \_ irq/54-pciehp
186 ? 00:00:00 \_ irq/55-pciehp
187 ? 00:00:00 \_ acpi_thermal_pm
188 ? 00:00:00 \_ kmpath_rdacd
189 ? 00:00:00 \_ kaluad
190 ? 00:00:00 \_ ipv6_addrconf
191 ? 00:00:00 \_ kstrp
448 ? 00:00:00 \_ mpt_poll_0
449 ? 00:00:00 \_ ata_sff
450 ? 00:00:00 \_ mpt/0
451 ? 00:00:00 \_ scsi_eh_0
452 ? 00:00:00 \_ scsi_tmf_0
453 ? 00:00:00 \_ scsi_eh_1
454 ? 00:00:00 \_ scsi_tmf_1
459 ? 00:00:00 \_ scsi_eh_2
460 ? 00:00:00 \_ scsi_tmf_2
468 ? 00:00:00 \_ irq/16-vmwgfx
470 ? 00:00:00 \_ ttm_swap
471 ? 00:00:00 \_ card0-crtc0
472 ? 00:00:00 \_ card0-crtc1
473 ? 00:00:00 \_ card0-crtc2
474 ? 00:00:00 \_ card0-crtc3
475 ? 00:00:00 \_ card0-crtc4
476 ? 00:00:00 \_ card0-crtc5
477 ? 00:00:00 \_ card0-crtc6
478 ? 00:00:00 \_ card0-crtc7
503 ? 00:00:00 \_ xfsalloc
504 ? 00:00:00 \_ xfs_mru_cache
505 ? 00:00:00 \_ xfs-buf/sda2
506 ? 00:00:00 \_ xfs-conv/sda2
507 ? 00:00:00 \_ xfs-cil/sda2
508 ? 00:00:00 \_ xfs-reclaim/sda
509 ? 00:00:00 \_ xfs-eofblocks/s
510 ? 00:00:00 \_ xfs-log/sda2
511 ? 00:00:00 \_ xfsaild/sda2
639 ? 00:00:00 \_ xfs-buf/sda3
640 ? 00:00:00 \_ xfs-conv/sda3
641 ? 00:00:00 \_ xfs-buf/sda1
642 ? 00:00:00 \_ xfs-cil/sda3
643 ? 00:00:00 \_ xfs-conv/sda1
644 ? 00:00:00 \_ xfs-reclaim/sda
645 ? 00:00:00 \_ xfs-cil/sda1
646 ? 00:00:00 \_ xfs-eofblocks/s
647 ? 00:00:00 \_ xfs-reclaim/sda
648 ? 00:00:00 \_ xfs-log/sda3
649 ? 00:00:00 \_ xfs-eofblocks/s
650 ? 00:00:00 \_ xfsaild/sda3
651 ? 00:00:00 \_ xfs-log/sda1
652 ? 00:00:00 \_ xfsaild/sda1
9556 ? 00:00:02 \_ kworker/u256:0-events_unbound
10224 ? 00:00:00 \_ cpuhp/1
10225 ? 00:00:00 \_ watchdog/1
10226 ? 00:00:00 \_ migration/1
10227 ? 00:00:00 \_ ksoftirqd/1
10228 ? 00:00:00 \_ kworker/1:0-xfs-eofblocks/sda2
10229 ? 00:00:00 \_ kworker/1:0H-events_highpri
10239 ? 00:00:00 \_ kworker/1:1H-kblockd
10246 ? 00:00:00 \_ kworker/u257:0-hci0
10247 ? 00:00:00 \_ kworker/u257:1-hci0
10347 ? 00:00:00 \_ kworker/1:3-cgroup_destroy
10539 ? 00:00:00 \_ kworker/u256:1-events_unbound
10544 ? 00:00:00 \_ kworker/0:2-ata_sff
10594 ? 00:00:00 \_ kworker/0:3-ata_sff
10624 ? 00:00:00 \_ kworker/0:0-events
1 ? 00:00:01 systemd
601 ? 00:00:00 systemd-journal
635 ? 00:00:00 systemd-udevd
685 ? 00:00:00 auditd
718 ? 00:00:00 VGAuthService
719 ? 00:00:07 vmtoolsd
721 ? 00:00:00 sssd
773 ? 00:00:00 \_ sssd_be
809 ? 00:00:00 \_ sssd_nss
723 ? 00:00:00 polkitd
726 ? 00:00:00 dbus-daemon
728 ? 00:00:00 NetworkManager
765 ? 00:00:00 sshd
10186 ? 00:00:00 \_ sshd
10188 ? 00:00:00 | \_ sshd
10189 pts/2 00:00:00 | \_ bash
10549 pts/2 00:00:00 | \_ su
10550 pts/2 00:00:00 | \_ bash
10581 pts/2 00:00:00 | \_ passwd
10449 ? 00:00:00 \_ sshd
10451 ? 00:00:30 | \_ sshd
10452 pts/1 00:00:00 | \_ bash
10625 pts/1 00:00:00 | \_ ps
10481 ? 00:00:00 \_ sshd
10483 ? 00:00:00 \_ sshd
10484 pts/0 00:00:00 \_ bash
10507 pts/0 00:19:38 \_ dd
767 ? 00:00:01 tuned
837 ? 00:00:00 rsyslogd
838 ? 00:00:00 systemd-logind
843 ? 00:00:00 crond
855 tty1 00:00:00 agetty
1302 ? 00:00:00 systemd
1305 ? 00:00:00 \_ (sd-pam)
10005 ? 00:00:00 anacron
#以进程树显示指定的进程
[root@rocky8 ~]# ps -f --forest -C sshd
UID PID PPID C STIME TTY TIME CMD
root 765 1 0 13:03 ? 00:00:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
root 10186 765 0 14:35 ? 00:00:00 \_ sshd: root [priv]
root 10188 10186 0 14:35 ? 00:00:00 | \_ sshd: root@pts/2
root 10449 765 0 14:41 ? 00:00:00 \_ sshd: root [priv]
root 10451 10449 2 14:41 ? 00:00:30 | \_ sshd: root@pts/1
root 10481 765 0 14:41 ? 00:00:00 \_ sshd: root [priv]
root 10483 10481 0 14:41 ? 00:00:00 \_ sshd: root@pts/0
[root@rocky8 ~]# ps -ef --forest | grep -v grep | grep sshd
root 765 1 0 13:03 ? 00:00:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512 -oGSSAPIKexAlgorithms=gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1- -oKexAlgorithms=curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 -oHostKeyAlgorithms=ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com -oPubkeyAcceptedKeyTypes=ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com -oCASignatureAlgorithms=ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-256,rsa-sha2-512,ssh-rsa
root 10186 765 0 14:35 ? 00:00:00 \_ sshd: root [priv]
root 10188 10186 0 14:35 ? 00:00:00 | \_ sshd: root@pts/2
root 10449 765 0 14:41 ? 00:00:00 \_ sshd: root [priv]
root 10451 10449 2 14:41 ? 00:00:30 | \_ sshd: root@pts/1
root 10481 765 0 14:41 ? 00:00:00 \_ sshd: root [priv]
root 10483 10481 0 14:41 ? 00:00:00 \_ sshd: root@pts/0
#要显示一个进程的所有线程,将显示LWP(轻量级进程)以及NLWP(轻量级进程数)列
[root@rocky8 ~]# ps -fL -C sshd
UID PID PPID LWP C NLWP STIME TTY TIME CMD
root 765 1 765 0 1 13:03 ? 00:00:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.c
root 10186 765 10186 0 1 14:35 ? 00:00:00 sshd: root [priv]
root 10188 10186 10188 0 1 14:35 ? 00:00:00 sshd: root@pts/2
root 10449 765 10449 0 1 14:41 ? 00:00:00 sshd: root [priv]
root 10451 10449 10451 2 1 14:41 ? 00:00:30 sshd: root@pts/1
root 10481 765 10481 0 1 14:41 ? 00:00:00 sshd: root [priv]
root 10483 10481 10483 0 1 14:41 ? 00:00:00 sshd: root@pts/0
#要列出所有格式说明符
[root@rocky8 ~]# ps L
%cpu %CPU
%mem %MEM
_left LLLLLLLL
_left2 L2L2L2L2
_right RRRRRRRR
_right2 R2R2R2R2
_unlimited U
_unlimited2 U2
alarm ALARM
args COMMAND
atime TIME
blocked BLOCKED
bsdstart START
bsdtime TIME
c C
caught CAUGHT
cgname CGNAME
cgroup CGROUP
class CLS
cls CLS
cmd CMD
comm COMMAND
command COMMAND
context CONTEXT
cp CP
cpuid CPUID
cputime TIME
cputimes TIME
drs DRS
dsiz DSIZ
egid EGID
egroup EGROUP
eip EIP
esp ESP
etime ELAPSED
etimes ELAPSED
euid EUID
euser EUSER
f F
fgid FGID
fgroup FGROUP
flag F
flags F
fname COMMAND
fsgid FSGID
fsgroup FSGROUP
fsuid FSUID
fsuser FSUSER
fuid FUID
fuser FUSER
gid GID
group GROUP
ignored IGNORED
intpri PRI
ipcns IPCNS
label LABEL
lastcpu C
lim LIM
longtname TTY
lsession SESSION
lstart STARTED
luid LUID
lwp LWP
lxc LXC
m_drs DRS
m_size SIZE
m_trs TRS
machine MACHINE
maj_flt MAJFL
majflt MAJFLT
min_flt MINFL
minflt MINFLT
mntns MNTNS
netns NETNS
ni NI
nice NI
nlwp NLWP
numa NUMA
nwchan WCHAN
opri PRI
ouid OWNER
pagein PAGEIN
pcpu %CPU
pending PENDING
pgid PGID
pgrp PGRP
pid PID
pidns PIDNS
pmem %MEM
policy POL
ppid PPID
pri PRI
pri_api API
pri_bar BAR
pri_baz BAZ
pri_foo FOO
priority PRI
psr PSR
rgid RGID
rgroup RGROUP
rss RSS
rssize RSS
rsz RSZ
rtprio RTPRIO
ruid RUID
ruser RUSER
s S
sched SCH
seat SEAT
sess SESS
session SESS
sgi_p P
sgi_rss RSS
sgid SGID
sgroup SGROUP
sid SID
sig PENDING
sig_block BLOCKED
sig_catch CATCHED
sig_ignore IGNORED
sig_pend SIGNAL
sigcatch CAUGHT
sigignore IGNORED
sigmask BLOCKED
size SIZE
slice SLICE
spid SPID
stackp STACKP
start STARTED
start_stack STACKP
start_time START
stat STAT
state S
stime STIME
suid SUID
supgid SUPGID
supgrp SUPGRP
suser SUSER
svgid SVGID
svgroup SVGROUP
svuid SVUID
svuser SVUSER
sz SZ
tgid TGID
thcount THCNT
tid TID
time TIME
times TIME
tname TTY
tpgid TPGID
trs TRS
trss TRSS
tsig PENDING
tsiz TSIZ
tt TT
tty TT
tty4 TTY
tty8 TTY
ucmd CMD
ucomm COMMAND
uid UID
uid_hack UID
uname USER
unit UNIT
user USER
userns USERNS
util C
utsns UTSNS
uunit UUNIT
vsize VSZ
vsz VSZ
wchan WCHAN
wname WCHAN
zone ZONE
#查看进程的PID,PPID,用户名和命令
[root@rocky8 ~]# ps -eo pid,ppid,user,cmd
PID PPID USER CMD
1 0 root /usr/lib/systemd/systemd --switched-root --system --deserialize 17
2 0 root [kthreadd]
3 2 root [rcu_gp]
4 2 root [rcu_par_gp]
6 2 root [kworker/0:0H-events_highpri]
9 2 root [mm_percpu_wq]
10 2 root [ksoftirqd/0]
11 2 root [rcu_sched]
12 2 root [migration/0]
13 2 root [watchdog/0]
14 2 root [cpuhp/0]
16 2 root [kdevtmpfs]
17 2 root [netns]
18 2 root [kauditd]
19 2 root [khungtaskd]
20 2 root [oom_reaper]
21 2 root [writeback]
22 2 root [kcompactd0]
23 2 root [ksmd]
24 2 root [khugepaged]
25 2 root [crypto]
26 2 root [kintegrityd]
27 2 root [kblockd]
28 2 root [blkcg_punt_bio]
29 2 root [tpm_dev_wq]
30 2 root [md]
31 2 root [edac-poller]
32 2 root [watchdogd]
33 2 root [kworker/0:1H-xfs-log/sda2]
61 2 root [kswapd0]
154 2 root [kthrotld]
155 2 root [irq/24-pciehp]
156 2 root [irq/25-pciehp]
157 2 root [irq/26-pciehp]
158 2 root [irq/27-pciehp]
159 2 root [irq/28-pciehp]
160 2 root [irq/29-pciehp]
161 2 root [irq/30-pciehp]
162 2 root [irq/31-pciehp]
163 2 root [irq/32-pciehp]
164 2 root [irq/33-pciehp]
165 2 root [irq/34-pciehp]
166 2 root [irq/35-pciehp]
167 2 root [irq/36-pciehp]
168 2 root [irq/37-pciehp]
169 2 root [irq/38-pciehp]
170 2 root [irq/39-pciehp]
171 2 root [irq/40-pciehp]
172 2 root [irq/41-pciehp]
173 2 root [irq/42-pciehp]
174 2 root [irq/43-pciehp]
175 2 root [irq/44-pciehp]
176 2 root [irq/45-pciehp]
177 2 root [irq/46-pciehp]
178 2 root [irq/47-pciehp]
179 2 root [irq/48-pciehp]
180 2 root [irq/49-pciehp]
181 2 root [irq/50-pciehp]
182 2 root [irq/51-pciehp]
183 2 root [irq/52-pciehp]
184 2 root [irq/53-pciehp]
185 2 root [irq/54-pciehp]
186 2 root [irq/55-pciehp]
187 2 root [acpi_thermal_pm]
188 2 root [kmpath_rdacd]
189 2 root [kaluad]
190 2 root [ipv6_addrconf]
191 2 root [kstrp]
448 2 root [mpt_poll_0]
449 2 root [ata_sff]
450 2 root [mpt/0]
451 2 root [scsi_eh_0]
452 2 root [scsi_tmf_0]
453 2 root [scsi_eh_1]
454 2 root [scsi_tmf_1]
459 2 root [scsi_eh_2]
460 2 root [scsi_tmf_2]
468 2 root [irq/16-vmwgfx]
470 2 root [ttm_swap]
471 2 root [card0-crtc0]
472 2 root [card0-crtc1]
473 2 root [card0-crtc2]
474 2 root [card0-crtc3]
475 2 root [card0-crtc4]
476 2 root [card0-crtc5]
477 2 root [card0-crtc6]
478 2 root [card0-crtc7]
503 2 root [xfsalloc]
504 2 root [xfs_mru_cache]
505 2 root [xfs-buf/sda2]
506 2 root [xfs-conv/sda2]
507 2 root [xfs-cil/sda2]
508 2 root [xfs-reclaim/sda]
509 2 root [xfs-eofblocks/s]
510 2 root [xfs-log/sda2]
511 2 root [xfsaild/sda2]
601 1 root /usr/lib/systemd/systemd-journald
635 1 root /usr/lib/systemd/systemd-udevd
639 2 root [xfs-buf/sda3]
640 2 root [xfs-conv/sda3]
641 2 root [xfs-buf/sda1]
642 2 root [xfs-cil/sda3]
643 2 root [xfs-conv/sda1]
644 2 root [xfs-reclaim/sda]
645 2 root [xfs-cil/sda1]
646 2 root [xfs-eofblocks/s]
647 2 root [xfs-reclaim/sda]
648 2 root [xfs-log/sda3]
649 2 root [xfs-eofblocks/s]
650 2 root [xfsaild/sda3]
651 2 root [xfs-log/sda1]
652 2 root [xfsaild/sda1]
685 1 root /sbin/auditd
718 1 root /usr/bin/VGAuthService -s
719 1 root /usr/bin/vmtoolsd
721 1 root /usr/sbin/sssd -i --logger=files
723 1 polkitd /usr/lib/polkit-1/polkitd --no-debug
726 1 dbus /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
728 1 root /usr/sbin/NetworkManager --no-daemon
765 1 root /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@open
767 1 root /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
773 721 root /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
809 721 root /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
837 1 root /usr/sbin/rsyslogd -n
838 1 root /usr/lib/systemd/systemd-logind
843 1 root /usr/sbin/crond -n
855 1 root /sbin/agetty -o -p -- \u --noclear tty1 linux
1302 1 root /usr/lib/systemd/systemd --user
1305 1302 root (sd-pam)
9556 2 root [kworker/u256:0-events_unbound]
10005 1 root /usr/sbin/anacron -s
10186 765 root sshd: root [priv]
10188 10186 root sshd: root@pts/2
10189 10188 root -bash
10224 2 root [cpuhp/1]
10225 2 root [watchdog/1]
10226 2 root [migration/1]
10227 2 root [ksoftirqd/1]
10228 2 root [kworker/1:0-xfs-eofblocks/sda2]
10229 2 root [kworker/1:0H-events_highpri]
10239 2 root [kworker/1:1H-kblockd]
10246 2 root [kworker/u257:0-hci0]
10247 2 root [kworker/u257:1-hci0]
10347 2 root [kworker/1:3-cgroup_destroy]
10449 765 root sshd: root [priv]
10451 10449 root sshd: root@pts/1
10452 10451 root -bash
10481 765 root sshd: root [priv]
10483 10481 root sshd: root@pts/0
10484 10483 root -bash
10507 10484 root dd if=/dev/zero of=/dev/null
10539 2 root [kworker/u256:1-events_unbound]
10544 2 root [kworker/0:2-ata_sff]
10549 10189 root su - raymond
10550 10549 raymond -bash
10581 10550 root passwd
10594 2 root [kworker/0:3-events]
10624 2 root [kworker/0:0-ata_sff]
10630 2 root [kworker/0:1-ata_sff]
10633 10452 root ps -eo pid,ppid,user,cmd
#自定义格式显示文件系统组,ni值开始时间和进程的时间
[root@rocky8 ~]# echo $BASHPID
10452
[root@rocky8 ~]# ps -p 10452 -o pid,ppid,fgroup,ni,lstart,etime
PID PPID FGROUP NI STARTED ELAPSED
10452 10451 root 0 Sun Oct 31 14:41:16 2021 23:19
#使用其PID查找进程名称:
[root@rocky8 ~]# ps -p 10452 -o comm=
bash
#要以其名称选择特定进程,显示其所有子进程
[root@rocky8 ~]# ps -C sshd,bash
PID TTY TIME CMD
765 ? 00:00:00 sshd
10186 ? 00:00:00 sshd
10188 ? 00:00:00 sshd
10189 pts/2 00:00:00 bash
10449 ? 00:00:00 sshd
10451 ? 00:00:30 sshd
10452 pts/1 00:00:00 bash
10481 ? 00:00:00 sshd
10483 ? 00:00:00 sshd
10484 pts/0 00:00:00 bash
10550 pts/2 00:00:00 bash
#查找指定进程名所有的所属PID,在编写需要从std输出或文件读取PID的脚本时这个参数很有用
[root@rocky8 ~]# ps -C httpd,sshd -o pid=
765
10186
10188
10449
10451
10481
10483
#检查一个进程的执行时间
[root@rocky8 ~]# ps -eo comm,etime,user | grep sshd
sshd 02:02:50 root
sshd 30:42 root
sshd 30:42 root
sshd 25:24 root
sshd 25:24 root
sshd 25:06 root
sshd 25:06 root
#排序,查找占用最多内存和CPU的进程
[root@rocky8 ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
PID PPID CMD %MEM %CPU
809 721 /usr/libexec/sssd/sssd_nss 5.1 0.0
767 1 /usr/libexec/platform-pytho 3.7 0.0
723 1 /usr/lib/polkit-1/polkitd - 3.0 0.0
728 1 /usr/sbin/NetworkManager -- 2.2 0.0
773 721 /usr/libexec/sssd/sssd_be - 1.8 0.0
721 1 /usr/sbin/sssd -i --logger= 1.7 0.0
718 1 /usr/bin/VGAuthService -s 1.4 0.0
1 0 /usr/lib/systemd/systemd -- 1.4 0.0
719 1 /usr/bin/vmtoolsd 1.2 0.1
[root@rocky8 ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
PID PPID CMD %MEM %CPU
10507 10484 dd if=/dev/zero of=/dev/nul 0.1 98.0
10451 10449 sshd: root@pts/1 0.8 1.9
719 1 /usr/bin/vmtoolsd 1.2 0.1
1 0 /usr/lib/systemd/systemd -- 1.4 0.0
2 0 [kthreadd] 0.0 0.0
3 2 [rcu_gp] 0.0 0.0
4 2 [rcu_par_gp] 0.0 0.0
6 2 [kworker/0:0H-events_highpr 0.0 0.0
9 2 [mm_percpu_wq] 0.0 0.0
#显示安全信息
[root@rocky8 ~]# ps -eM
LABEL PID TTY TIME CMD
- 1 ? 00:00:01 systemd
- 2 ? 00:00:00 kthreadd
- 3 ? 00:00:00 rcu_gp
- 4 ? 00:00:00 rcu_par_gp
- 6 ? 00:00:00 kworker/0:0H-events_highpri
- 9 ? 00:00:00 mm_percpu_wq
- 10 ? 00:00:00 ksoftirqd/0
- 11 ? 00:00:00 rcu_sched
- 12 ? 00:00:00 migration/0
- 13 ? 00:00:00 watchdog/0
- 14 ? 00:00:00 cpuhp/0
- 16 ? 00:00:00 kdevtmpfs
- 17 ? 00:00:00 netns
- 18 ? 00:00:00 kauditd
- 19 ? 00:00:00 khungtaskd
- 20 ? 00:00:00 oom_reaper
- 21 ? 00:00:00 writeback
- 22 ? 00:00:00 kcompactd0
- 23 ? 00:00:00 ksmd
- 24 ? 00:00:00 khugepaged
- 25 ? 00:00:00 crypto
- 26 ? 00:00:00 kintegrityd
- 27 ? 00:00:00 kblockd
- 28 ? 00:00:00 blkcg_punt_bio
- 29 ? 00:00:00 tpm_dev_wq
- 30 ? 00:00:00 md
- 31 ? 00:00:00 edac-poller
- 32 ? 00:00:00 watchdogd
- 33 ? 00:00:00 kworker/0:1H-xfs-log/sda2
- 61 ? 00:00:00 kswapd0
- 154 ? 00:00:00 kthrotld
- 155 ? 00:00:00 irq/24-pciehp
- 156 ? 00:00:00 irq/25-pciehp
- 157 ? 00:00:00 irq/26-pciehp
- 158 ? 00:00:00 irq/27-pciehp
- 159 ? 00:00:00 irq/28-pciehp
- 160 ? 00:00:00 irq/29-pciehp
- 161 ? 00:00:00 irq/30-pciehp
- 162 ? 00:00:00 irq/31-pciehp
- 163 ? 00:00:00 irq/32-pciehp
- 164 ? 00:00:00 irq/33-pciehp
- 165 ? 00:00:00 irq/34-pciehp
- 166 ? 00:00:00 irq/35-pciehp
- 167 ? 00:00:00 irq/36-pciehp
- 168 ? 00:00:00 irq/37-pciehp
- 169 ? 00:00:00 irq/38-pciehp
- 170 ? 00:00:00 irq/39-pciehp
- 171 ? 00:00:00 irq/40-pciehp
- 172 ? 00:00:00 irq/41-pciehp
- 173 ? 00:00:00 irq/42-pciehp
- 174 ? 00:00:00 irq/43-pciehp
- 175 ? 00:00:00 irq/44-pciehp
- 176 ? 00:00:00 irq/45-pciehp
- 177 ? 00:00:00 irq/46-pciehp
- 178 ? 00:00:00 irq/47-pciehp
- 179 ? 00:00:00 irq/48-pciehp
- 180 ? 00:00:00 irq/49-pciehp
- 181 ? 00:00:00 irq/50-pciehp
- 182 ? 00:00:00 irq/51-pciehp
- 183 ? 00:00:00 irq/52-pciehp
- 184 ? 00:00:00 irq/53-pciehp
- 185 ? 00:00:00 irq/54-pciehp
- 186 ? 00:00:00 irq/55-pciehp
- 187 ? 00:00:00 acpi_thermal_pm
- 188 ? 00:00:00 kmpath_rdacd
- 189 ? 00:00:00 kaluad
- 190 ? 00:00:00 ipv6_addrconf
- 191 ? 00:00:00 kstrp
- 448 ? 00:00:00 mpt_poll_0
- 449 ? 00:00:00 ata_sff
- 450 ? 00:00:00 mpt/0
- 451 ? 00:00:00 scsi_eh_0
- 452 ? 00:00:00 scsi_tmf_0
- 453 ? 00:00:00 scsi_eh_1
- 454 ? 00:00:00 scsi_tmf_1
- 459 ? 00:00:00 scsi_eh_2
- 460 ? 00:00:00 scsi_tmf_2
- 468 ? 00:00:00 irq/16-vmwgfx
- 470 ? 00:00:00 ttm_swap
- 471 ? 00:00:00 card0-crtc0
- 472 ? 00:00:00 card0-crtc1
- 473 ? 00:00:00 card0-crtc2
- 474 ? 00:00:00 card0-crtc3
- 475 ? 00:00:00 card0-crtc4
- 476 ? 00:00:00 card0-crtc5
- 477 ? 00:00:00 card0-crtc6
- 478 ? 00:00:00 card0-crtc7
- 503 ? 00:00:00 xfsalloc
- 504 ? 00:00:00 xfs_mru_cache
- 505 ? 00:00:00 xfs-buf/sda2
- 506 ? 00:00:00 xfs-conv/sda2
- 507 ? 00:00:00 xfs-cil/sda2
- 508 ? 00:00:00 xfs-reclaim/sda
- 509 ? 00:00:00 xfs-eofblocks/s
- 510 ? 00:00:00 xfs-log/sda2
- 511 ? 00:00:00 xfsaild/sda2
- 601 ? 00:00:00 systemd-journal
- 635 ? 00:00:00 systemd-udevd
- 639 ? 00:00:00 xfs-buf/sda3
- 640 ? 00:00:00 xfs-conv/sda3
- 641 ? 00:00:00 xfs-buf/sda1
- 642 ? 00:00:00 xfs-cil/sda3
- 643 ? 00:00:00 xfs-conv/sda1
- 644 ? 00:00:00 xfs-reclaim/sda
- 645 ? 00:00:00 xfs-cil/sda1
- 646 ? 00:00:00 xfs-eofblocks/s
- 647 ? 00:00:00 xfs-reclaim/sda
- 648 ? 00:00:00 xfs-log/sda3
- 649 ? 00:00:00 xfs-eofblocks/s
- 650 ? 00:00:00 xfsaild/sda3
- 651 ? 00:00:00 xfs-log/sda1
- 652 ? 00:00:00 xfsaild/sda1
- 685 ? 00:00:00 auditd
- 718 ? 00:00:00 VGAuthService
- 719 ? 00:00:08 vmtoolsd
- 721 ? 00:00:00 sssd
- 723 ? 00:00:00 polkitd
- 726 ? 00:00:00 dbus-daemon
- 728 ? 00:00:00 NetworkManager
- 765 ? 00:00:00 sshd
- 767 ? 00:00:01 tuned
- 773 ? 00:00:00 sssd_be
- 809 ? 00:00:00 sssd_nss
- 837 ? 00:00:00 rsyslogd
- 838 ? 00:00:00 systemd-logind
- 843 ? 00:00:00 crond
- 855 tty1 00:00:00 agetty
- 1302 ? 00:00:00 systemd
- 1305 ? 00:00:00 (sd-pam)
- 9556 ? 00:00:02 kworker/u256:0-events_unbound
- 10005 ? 00:00:00 anacron
- 10186 ? 00:00:00 sshd
- 10188 ? 00:00:00 sshd
- 10189 pts/2 00:00:00 bash
- 10224 ? 00:00:00 cpuhp/1
- 10225 ? 00:00:00 watchdog/1
- 10226 ? 00:00:00 migration/1
- 10227 ? 00:00:00 ksoftirqd/1
- 10228 ? 00:00:00 kworker/1:0-xfs-eofblocks/sda2
- 10229 ? 00:00:00 kworker/1:0H-events_highpri
- 10239 ? 00:00:00 kworker/1:1H-kblockd
- 10246 ? 00:00:00 kworker/u257:0-hci0
- 10247 ? 00:00:00 kworker/u257:1-hci0
- 10347 ? 00:00:00 kworker/1:3-cgroup_destroy
- 10449 ? 00:00:00 sshd
- 10451 ? 00:00:30 sshd
- 10452 pts/1 00:00:00 bash
- 10481 ? 00:00:00 sshd
- 10483 ? 00:00:00 sshd
- 10484 pts/0 00:00:00 bash
- 10507 pts/0 00:25:35 dd
- 10539 ? 00:00:00 kworker/u256:1-events_unbound
- 10544 ? 00:00:00 kworker/0:2-ata_sff
- 10549 pts/2 00:00:00 su
- 10550 pts/2 00:00:00 bash
- 10581 pts/2 00:00:00 passwd
- 10594 ? 00:00:00 kworker/0:3-events
- 10630 ? 00:00:00 kworker/0:1-ata_sff
- 10645 pts/1 00:00:00 ps
[root@rocky8 ~]# ps --context
PID CONTEXT COMMAND
10452 - -bash
10646 - ps --context
#使用以下命令以用户定义的格式显示安全信息
[root@rocky8 ~]# ps -eo euser,ruser,suser,fuser,f,comm,label
EUSER RUSER SUSER FUSER F COMMAND LABEL
root root root root 4 systemd -
root root root root 1 kthreadd -
root root root root 1 rcu_gp -
root root root root 1 rcu_par_gp -
root root root root 1 kworker/0:0H-ev -
root root root root 1 mm_percpu_wq -
root root root root 1 ksoftirqd/0 -
root root root root 1 rcu_sched -
root root root root 1 migration/0 -
root root root root 5 watchdog/0 -
root root root root 1 cpuhp/0 -
root root root root 5 kdevtmpfs -
root root root root 1 netns -
root root root root 1 kauditd -
root root root root 1 khungtaskd -
root root root root 1 oom_reaper -
root root root root 1 writeback -
root root root root 1 kcompactd0 -
root root root root 1 ksmd -
root root root root 1 khugepaged -
root root root root 1 crypto -
root root root root 1 kintegrityd -
root root root root 1 kblockd -
root root root root 1 blkcg_punt_bio -
root root root root 1 tpm_dev_wq -
root root root root 1 md -
root root root root 1 edac-poller -
root root root root 1 watchdogd -
root root root root 1 kworker/0:1H-kb -
root root root root 1 kswapd0 -
root root root root 1 kthrotld -
root root root root 1 irq/24-pciehp -
root root root root 1 irq/25-pciehp -
root root root root 1 irq/26-pciehp -
root root root root 1 irq/27-pciehp -
root root root root 1 irq/28-pciehp -
root root root root 1 irq/29-pciehp -
root root root root 1 irq/30-pciehp -
root root root root 1 irq/31-pciehp -
root root root root 1 irq/32-pciehp -
root root root root 1 irq/33-pciehp -
root root root root 1 irq/34-pciehp -
root root root root 1 irq/35-pciehp -
root root root root 1 irq/36-pciehp -
root root root root 1 irq/37-pciehp -
root root root root 1 irq/38-pciehp -
root root root root 1 irq/39-pciehp -
root root root root 1 irq/40-pciehp -
root root root root 1 irq/41-pciehp -
root root root root 1 irq/42-pciehp -
root root root root 1 irq/43-pciehp -
root root root root 1 irq/44-pciehp -
root root root root 1 irq/45-pciehp -
root root root root 1 irq/46-pciehp -
root root root root 1 irq/47-pciehp -
root root root root 1 irq/48-pciehp -
root root root root 1 irq/49-pciehp -
root root root root 1 irq/50-pciehp -
root root root root 1 irq/51-pciehp -
root root root root 1 irq/52-pciehp -
root root root root 1 irq/53-pciehp -
root root root root 1 irq/54-pciehp -
root root root root 1 irq/55-pciehp -
root root root root 1 acpi_thermal_pm -
root root root root 1 kmpath_rdacd -
root root root root 1 kaluad -
root root root root 1 ipv6_addrconf -
root root root root 1 kstrp -
root root root root 1 mpt_poll_0 -
root root root root 1 ata_sff -
root root root root 1 mpt/0 -
root root root root 1 scsi_eh_0 -
root root root root 1 scsi_tmf_0 -
root root root root 1 scsi_eh_1 -
root root root root 1 scsi_tmf_1 -
root root root root 1 scsi_eh_2 -
root root root root 1 scsi_tmf_2 -
root root root root 1 irq/16-vmwgfx -
root root root root 1 ttm_swap -
root root root root 1 card0-crtc0 -
root root root root 1 card0-crtc1 -
root root root root 1 card0-crtc2 -
root root root root 1 card0-crtc3 -
root root root root 1 card0-crtc4 -
root root root root 1 card0-crtc5 -
root root root root 1 card0-crtc6 -
root root root root 1 card0-crtc7 -
root root root root 1 xfsalloc -
root root root root 1 xfs_mru_cache -
root root root root 1 xfs-buf/sda2 -
root root root root 1 xfs-conv/sda2 -
root root root root 1 xfs-cil/sda2 -
root root root root 1 xfs-reclaim/sda -
root root root root 1 xfs-eofblocks/s -
root root root root 1 xfs-log/sda2 -
root root root root 1 xfsaild/sda2 -
root root root root 4 systemd-journal -
root root root root 4 systemd-udevd -
root root root root 1 xfs-buf/sda3 -
root root root root 1 xfs-conv/sda3 -
root root root root 1 xfs-buf/sda1 -
root root root root 1 xfs-cil/sda3 -
root root root root 1 xfs-conv/sda1 -
root root root root 1 xfs-reclaim/sda -
root root root root 1 xfs-cil/sda1 -
root root root root 1 xfs-eofblocks/s -
root root root root 1 xfs-reclaim/sda -
root root root root 1 xfs-log/sda3 -
root root root root 1 xfs-eofblocks/s -
root root root root 1 xfsaild/sda3 -
root root root root 1 xfs-log/sda1 -
root root root root 1 xfsaild/sda1 -
root root root root 5 auditd -
root root root root 4 VGAuthService -
root root root root 4 vmtoolsd -
root root root root 4 sssd -
polkitd polkitd polkitd polkitd 4 polkitd -
dbus dbus dbus dbus 4 dbus-daemon -
root root root root 4 NetworkManager -
root root root root 4 sshd -
root root root root 4 tuned -
root root root root 4 sssd_be -
root root root root 4 sssd_nss -
root root root root 4 rsyslogd -
root root root root 4 systemd-logind -
root root root root 4 crond -
root root root root 4 agetty -
root root root root 4 systemd -
root root root root 5 (sd-pam) -
root root root root 1 kworker/u256:0- -
root root root root 1 anacron -
root root root root 4 sshd -
root root root root 5 sshd -
root root root root 0 bash -
root root root root 1 cpuhp/1 -
root root root root 5 watchdog/1 -
root root root root 1 migration/1 -
root root root root 1 ksoftirqd/1 -
root root root root 1 kworker/1:0-xfs -
root root root root 1 kworker/1:0H-ev -
root root root root 1 kworker/1:1H-kb -
root root root root 1 kworker/u257:0- -
root root root root 1 kworker/u257:1- -
root root root root 1 kworker/1:3-cgr -
root root root root 4 sshd -
root root root root 5 sshd -
root root root root 0 bash -
root root root root 4 sshd -
root root root root 5 sshd -
root root root root 0 bash -
root root root root 0 dd -
root root root root 1 kworker/u256:1- -
root root root root 1 kworker/0:2-ata -
root root root root 4 su -
raymond raymond raymond raymond 4 bash -
root raymond root root 4 passwd -
root root root root 1 kworker/0:3-eve -
root root root root 1 kworker/0:1-ata -
root root root root 0 ps -
#使用watch实用程序执行重复的输出以实现对就程进行实时的监视,如下面的命令显示每秒钟的监视
[root@rocky8 ~]# watch -n 1 'ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head'
Every 1.0s: ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head rocky8: Sun Oct 31 15:08:58 2021
PID PPID CMD %MEM %CPU
809 721 /usr/libexec/sssd/sssd_nss 5.1 0.0
767 1 /usr/libexec/platform-pytho 3.7 0.0
723 1 /usr/lib/polkit-1/polkitd - 3.0 0.0
728 1 /usr/sbin/NetworkManager -- 2.2 0.0
773 721 /usr/libexec/sssd/sssd_be - 1.8 0.0
721 1 /usr/sbin/sssd -i --logger= 1.7 0.0
718 1 /usr/bin/VGAuthService -s 1.4 0.0
1 0 /usr/lib/systemd/systemd -- 1.4 0.0
719 1 /usr/bin/vmtoolsd 1.2 0.1
面试题:找到未知进程的执行程序文件路径
[root@rocky8 ~]# echo $BASHPID
10452
[root@rocky8 ~]# ls -l /proc/10452/exe
lrwxrwxrwx 1 root root 0 Oct 31 14:59 /proc/10452/exe -> /usr/bin/bash
范例:查看优先级和CPU绑定关系
[root@rocky8 ~]# ps axo pid,cmd,ni,pri,psr,rtprio |grep migration
12 [migration/0] - 139 0 99
10226 [migration/1] - 139 1 99
10675 grep --color=auto migration 0 19 0 -
[root@rocky8 ~]# ps axo pid,cmd,ni,pri,psr |grep dd
2 [kthreadd] 0 19 0
190 [ipv6_addrconf] -20 39 0
10507 dd if=/dev/zero of=/dev/nul 0 19 1
10677 grep --color=auto dd 0 19 0
范例:实现进程和CPU的绑定
[root@rocky8 ~]# taskset --help
Usage: taskset [options] [mask | cpu-list] [pid|cmd [args...]]
Show or change the CPU affinity of a process.
Options:
-a, --all-tasks operate on all the tasks (threads) for a given pid
-p, --pid operate on existing given pid
-c, --cpu-list display and specify cpus in list format
-h, --help display this help
-V, --version display version
The default behavior is to run a new command:
taskset 03 sshd -b 1024
You can retrieve the mask of an existing task:
taskset -p 700
Or set it:
taskset -p 03 700
List format uses a comma-separated list instead of a mask:
taskset -pc 0,3,7-11 700
Ranges in list format can take a stride argument:
e.g. 0-31:2 is equivalent to mask 0x55555555
For more details see taskset(1).
2.3 查看进程信息prtstat
可以显示进程信息,来自于psmisc包
格式:
prtstat [options] PID ...
选项:
-r raw 格式显示
范例:
[root@rocky8 ~]# prtstat 1
Process: systemd State: S (sleeping)
CPU#: 0 TTY: 0:0 Threads: 1
Process, Group and Session IDs
Process ID: 1 Parent ID: 0
Group ID: 1 Session ID: 1
T Group ID: -1
Page Faults
This Process (minor major): 11337 112
Child Processes (minor major): 843240 193
CPU Times
This Process (user system guest blkio): 0.19 1.55 0.00 0.12
Child processes (user system guest): 5.59 6.46 0.00
Memory
Vsize: 188 MB
RSS: 11 MB RSS Limit: 18446744073709 MB
Code Start: 0x55b2f93c0000 Code Stop: 0x55b2f9501359
Stack Start: 0x7ffc98741540
Stack Pointer (ESP): 0 Inst Pointer (EIP): 0
Scheduling
Policy: normal
Nice: 0 RT Priority: 0 (non RT)
[root@rocky8 ~]# prtstat -r 1
pid: 1 comm: systemd
state: S ppid: 0
pgrp: 1 session: 1
tty_nr: 0 tpgid: -1
flags: 400100 minflt: 11337
cminflt: 843240 majflt: 112
cmajflt: 193 utime: 19
stime: 155 cutime: 559
cstime: 646 priority: 20
nice: 0 num_threads: 1
itrealvalue: 0 starttime: 1
vsize: 188145664 rss: 2852
rsslim: 18446744073709551615 startcode: 94227173998592
endcode: 94227175314265 startstack: 140722866230592
kstkesp: 0 kstkeip: 0
wchan: 1 nswap: 0
cnswap: 1 exit_signal: 17
processor: 0 rt_priority: 0
policy: 0 delayaccr_blkio_ticks: 12
guest_time: 0 cguest_time: 0
2.4 设置和调整进程优先级
进程优先级调整
- 静态优先级:100-139
- 进程默认启动时的nice值为0,优先级为120
- 只有根用户才能降低nice值(提高优先性)
nice命令
以指定的优先级来启动进程
nice [OPTION] [COMMAND [ARG]...]
-n, --adjustment=N add integer N to the niceness (default 10)
renice命令
可以调整正在执行中的进程的优先级
renice [-n] priority pid...
查看
ps axo pid,comm,ni
范例:
[root@rocky8 ~]# nice -n -5 ping 127.0.0.1 #nice -n 指定优先级
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.044 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.028 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.027 ms
...
[root@rocky8 ~]# ps axo pid,cmd,nice |grep ping
10725 ping 127.0.0.1 -5
10727 grep --color=auto ping 0
[root@rocky8 ~]# prtstat 10725
Process: ping State: S (sleeping)
CPU#: 0 TTY: 136:1 Threads: 1
Process, Group and Session IDs
Process ID: 10725 Parent ID: 10452
Group ID: 10725 Session ID: 10452
T Group ID: 10725
Page Faults
This Process (minor major): 289 0
Child Processes (minor major): 0 0
CPU Times
This Process (user system guest blkio): 0.00 0.00 0.00 0.00
Child processes (user system guest): 0.00 0.00 0.00
Memory
Vsize: 33 MB
RSS: 2433 kB RSS Limit: 18446744073709 MB
Code Start: 0x55a1bc407000 Code Stop: 0x55a1bc414f28
Stack Start: 0x7ffdec551ec0
Stack Pointer (ESP): 0 Inst Pointer (EIP): 0
Scheduling
Policy: normal
Nice: -5 RT Priority: -5 (non RT)
[root@rocky8 ~]# renice -n 19 10725 #更改优先级
10725 (process ID) old priority -5, new priority 19
[root@rocky8 ~]# ps axo pid,cmd,nice |grep ping
10725 ping 127.0.0.1 19
10732 grep --color=auto ping 0
[root@rocky8 ~]# renice -n 25 10725
10725 (process ID) old priority 19, new priority 19
[root@rocky8 ~]# ps axo pid,cmd,nice |grep ping
10725 ping 127.0.0.1 19
10735 grep --color=auto ping 0
#nice优先级不能超过19
[root@rocky8 ~]# ps axo pid,cmd,nice,pri,rtprio
PID CMD NI PRI RTPRIO
1 /usr/lib/systemd/systemd -- 0 19 -
2 [kthreadd] 0 19 -
3 [rcu_gp] -20 39 -
4 [rcu_par_gp] -20 39 -
6 [kworker/0:0H-events_highpr -20 39 -
9 [mm_percpu_wq] -20 39 -
10 [ksoftirqd/0] 0 19 -
11 [rcu_sched] 0 19 -
12 [migration/0] - 139 99
13 [watchdog/0] - 139 99
14 [cpuhp/0] 0 19 -
16 [kdevtmpfs] 0 19 -
17 [netns] -20 39 -
18 [kauditd] 0 19 -
19 [khungtaskd] 0 19 -
20 [oom_reaper] 0 19 -
21 [writeback] -20 39 -
22 [kcompactd0] 0 19 -
23 [ksmd] 5 14 -
24 [khugepaged] 19 0 -
25 [crypto] -20 39 -
26 [kintegrityd] -20 39 -
27 [kblockd] -20 39 -
28 [blkcg_punt_bio] -20 39 -
29 [tpm_dev_wq] -20 39 -
30 [md] -20 39 -
31 [edac-poller] -20 39 -
32 [watchdogd] - 139 99
33 [kworker/0:1H-kblockd] -20 39 -
61 [kswapd0] 0 19 -
154 [kthrotld] -20 39 -
155 [irq/24-pciehp] - 90 50
156 [irq/25-pciehp] - 90 50
157 [irq/26-pciehp] - 90 50
158 [irq/27-pciehp] - 90 50
159 [irq/28-pciehp] - 90 50
160 [irq/29-pciehp] - 90 50
161 [irq/30-pciehp] - 90 50
162 [irq/31-pciehp] - 90 50
163 [irq/32-pciehp] - 90 50
164 [irq/33-pciehp] - 90 50
165 [irq/34-pciehp] - 90 50
166 [irq/35-pciehp] - 90 50
167 [irq/36-pciehp] - 90 50
168 [irq/37-pciehp] - 90 50
169 [irq/38-pciehp] - 90 50
170 [irq/39-pciehp] - 90 50
171 [irq/40-pciehp] - 90 50
172 [irq/41-pciehp] - 90 50
173 [irq/42-pciehp] - 90 50
174 [irq/43-pciehp] - 90 50
175 [irq/44-pciehp] - 90 50
176 [irq/45-pciehp] - 90 50
177 [irq/46-pciehp] - 90 50
178 [irq/47-pciehp] - 90 50
179 [irq/48-pciehp] - 90 50
180 [irq/49-pciehp] - 90 50
181 [irq/50-pciehp] - 90 50
182 [irq/51-pciehp] - 90 50
183 [irq/52-pciehp] - 90 50
184 [irq/53-pciehp] - 90 50
185 [irq/54-pciehp] - 90 50
186 [irq/55-pciehp] - 90 50
187 [acpi_thermal_pm] -20 39 -
188 [kmpath_rdacd] -20 39 -
189 [kaluad] -20 39 -
190 [ipv6_addrconf] -20 39 -
191 [kstrp] -20 39 -
448 [mpt_poll_0] -20 39 -
449 [ata_sff] -20 39 -
450 [mpt/0] -20 39 -
451 [scsi_eh_0] 0 19 -
452 [scsi_tmf_0] -20 39 -
453 [scsi_eh_1] 0 19 -
454 [scsi_tmf_1] -20 39 -
459 [scsi_eh_2] 0 19 -
460 [scsi_tmf_2] -20 39 -
468 [irq/16-vmwgfx] - 90 50
470 [ttm_swap] -20 39 -
471 [card0-crtc0] - 90 50
472 [card0-crtc1] - 90 50
473 [card0-crtc2] - 90 50
474 [card0-crtc3] - 90 50
475 [card0-crtc4] - 90 50
476 [card0-crtc5] - 90 50
477 [card0-crtc6] - 90 50
478 [card0-crtc7] - 90 50
503 [xfsalloc] -20 39 -
504 [xfs_mru_cache] -20 39 -
505 [xfs-buf/sda2] -20 39 -
506 [xfs-conv/sda2] -20 39 -
507 [xfs-cil/sda2] -20 39 -
508 [xfs-reclaim/sda] -20 39 -
509 [xfs-eofblocks/s] -20 39 -
510 [xfs-log/sda2] -20 39 -
511 [xfsaild/sda2] 0 19 -
601 /usr/lib/systemd/systemd-jo 0 19 -
635 /usr/lib/systemd/systemd-ud 0 19 -
639 [xfs-buf/sda3] -20 39 -
640 [xfs-conv/sda3] -20 39 -
641 [xfs-buf/sda1] -20 39 -
642 [xfs-cil/sda3] -20 39 -
643 [xfs-conv/sda1] -20 39 -
644 [xfs-reclaim/sda] -20 39 -
645 [xfs-cil/sda1] -20 39 -
646 [xfs-eofblocks/s] -20 39 -
647 [xfs-reclaim/sda] -20 39 -
648 [xfs-log/sda3] -20 39 -
649 [xfs-eofblocks/s] -20 39 -
650 [xfsaild/sda3] 0 19 -
651 [xfs-log/sda1] -20 39 -
652 [xfsaild/sda1] 0 19 -
685 /sbin/auditd -4 23 -
718 /usr/bin/VGAuthService -s 0 19 -
719 /usr/bin/vmtoolsd 0 19 -
721 /usr/sbin/sssd -i --logger= 0 19 -
723 /usr/lib/polkit-1/polkitd - 0 19 -
726 /usr/bin/dbus-daemon --syst 0 19 -
728 /usr/sbin/NetworkManager -- 0 19 -
765 /usr/sbin/sshd -D -oCiphers 0 19 -
767 /usr/libexec/platform-pytho 0 19 -
773 /usr/libexec/sssd/sssd_be - 0 19 -
809 /usr/libexec/sssd/sssd_nss 0 19 -
837 /usr/sbin/rsyslogd -n 0 19 -
838 /usr/lib/systemd/systemd-lo 0 19 -
843 /usr/sbin/crond -n 0 19 -
855 /sbin/agetty -o -p -- \u -- 0 19 -
1302 /usr/lib/systemd/systemd -- 0 19 -
1305 (sd-pam) 0 19 -
9556 [kworker/u256:0-events_unbo 0 19 -
10186 sshd: root [priv] 0 19 -
10188 sshd: root@pts/2 0 19 -
10189 -bash 0 19 -
10224 [cpuhp/1] 0 19 -
10225 [watchdog/1] - 139 99
10226 [migration/1] - 139 99
10227 [ksoftirqd/1] 0 19 -
10228 [kworker/1:0-mm_percpu_wq] 0 19 -
10229 [kworker/1:0H-events_highpr -20 39 -
10239 [kworker/1:1H-kblockd] -20 39 -
10246 [kworker/u257:0-hci0] -20 39 -
10247 [kworker/u257:1-hci0] -20 39 -
10347 [kworker/1:3-cgroup_destroy 0 19 -
10449 sshd: root [priv] 0 19 -
10451 sshd: root@pts/1 0 19 -
10452 -bash 0 19 -
10481 sshd: root [priv] 0 19 -
10483 sshd: root@pts/0 0 19 -
10484 -bash 0 19 -
10539 [kworker/u256:1-events_unbo 0 19 -
10549 su - raymond 0 19 -
10550 -bash 0 19 -
10581 passwd 0 19 -
10690 [kworker/0:1-events] 0 19 -
10704 vim anaconda-ks.cfg 0 19 -
10720 [kworker/0:2-ata_sff] 0 19 -
10725 ping 127.0.0.1 19 0 -
10729 [kworker/0:0-ata_sff] 0 19 -
10736 ps axo pid,cmd,nice,pri,rtp 0 19 -
[root@rocky8 ~]# man ps
...
pri PRI priority of the process. Higher number means lower priority.
2.5 搜索进程
按条件搜索进程
- ps 选项 | grep ‘pattern’ 灵活
- pgrep 按预定义的模式
- /sbin/pidof 按确切的程序名称查看pid
范例:
[root@rocky8 ~]# ps aux |grep bash
root 10189 0.0 0.4 26244 3884 pts/2 Ss 14:35 0:00 -bash
root 10452 0.0 0.4 26244 4000 pts/1 Ss 14:41 0:00 -bash
root 10484 0.0 0.4 26244 3900 pts/0 Ss 14:41 0:00 -bash
raymond 10550 0.0 0.4 24120 3872 pts/2 S 14:51 0:00 -bash
root 10762 0.0 0.1 12136 1044 pts/0 S+ 16:47 0:00 grep --color=auto bash
2.5.1 pgrep
命令格式
pgrep [options] pattern
常用选项
-u uid: effective user,生效者
-U uid: real user,真正发起运行命令者
-t terminal: 与指定终端相关的进程
-l: 显示进程名
-a: 显示完整格式的进程名
-P pid: 显示指定进程的子进程
范例:
[root@rocky8 ~]# pgrep --help
Usage:
pgrep [options] <pattern>
Options:
-d, --delimiter <string> specify output delimiter
-l, --list-name list PID and process name
-a, --list-full list PID and full command line
-v, --inverse negates the matching
-w, --lightweight list all TID
-c, --count count of matching processes
-f, --full use full process name to match
-g, --pgroup <PGID,...> match listed process group IDs
-G, --group <GID,...> match real group IDs
-i, --ignore-case match case insensitively
-n, --newest select most recently started
-o, --oldest select least recently started
-P, --parent <PPID,...> match only child processes of the given parent
-s, --session <SID,...> match session IDs
-t, --terminal <tty,...> match by controlling terminal
-u, --euid <ID,...> match by effective IDs
-U, --uid <ID,...> match by real IDs
-x, --exact match exactly with the command name
-F, --pidfile <file> read PIDs from file
-L, --logpidfile fail if PID file is not locked
--ns <PID> match the processes that belong to the same
namespace as <pid>
--nslist <ns,...> list which namespaces will be considered for
the --ns option.
Available namespaces: ipc, mnt, net, pid, user, uts
-h, --help display this help and exit
-V, --version output version information and exit
For more details see pgrep(1).
[root@rocky8 ~]# dd if=/dev/zero of=/dev/null
[root@rocky8 ~]# pgrep dd
2
190
28954
[root@rocky8 ~]# pgrep -a dd
2 kthreadd
190 ipv6_addrconf
28954 dd if=/dev/zero of=/dev/null
[root@rocky8 ~]# pgrep -a ^dd
28954 dd if=/dev/zero of=/dev/null
[root@rocky8 ~]# pgrep -u raymond
[root@rocky8 ~]# pgrep -U raymond
[root@rocky8 ~]# su - raymond
Last login: Sun Oct 31 14:51:21 CST 2021 on pts/2
[root@rocky8 ~]# pgrep -u raymond
10770
[root@rocky8 ~]# pgrep -U raymond
10770
[raymond@rocky8 ~]$ passwd
Changing password for user raymond.
Current password:
[root@rocky8 ~]# pgrep -au raymond #u 有效用户
10770 -bash
[root@rocky8 ~]# pgrep -aU raymond #U 真正用户
10770 -bash
10799 passwd
[root@rocky8 ~]# ps axo pid,cmd,ruser,euser
...
10769 su - raymond root root
10770 -bash raymond raymond
10799 passwd raymond root
10802 [kworker/0:3] root root
10803 ps axo pid,cmd,ruser,euser root root
[raymond@rocky8 ~]$ tty
/dev/pts/0
[raymond@rocky8 ~]$ pgrep -t pts/0
10484
10769
10770
[raymond@rocky8 ~]$ pgrep -at pts/0
10484 -bash
10769 su - raymond
10770 -bash
2.5.2 pidof
命令格式
pidof [options] [program [...]]
常用选项:
-x 按脚本名称查找pid
范例:
[root@rocky8 ~]# pidof bash
10770 10484 10452 10189
[root@rocky8 ~]# vim test.sh
#!/bin/bash
#
#**********************************************************************************************
#Author: Raymond
#QQ: 88563128
#Date: 2021-10-31
#FileName: test.sh
#URL: raymond.blog.csdn.net
#Description: The test script
#Copyright (C): 2021 All rights reserved
#*********************************************************************************************
sleep 100
[root@rocky8 ~]# chmod +x test.sh
[root@rocky8 ~]# ./test.sh
[root@rocky8 ~]# pidof test.sh
[root@rocky8 ~]# pidof -x test.sh
10811
[root@rocky8 ~]# ps aux |grep bash
root 10189 0.0 0.4 26244 3884 pts/2 Ss 14:35 0:00 -bash
root 10452 0.0 0.4 26244 4000 pts/1 Ss 14:41 0:00 -bash
root 10484 0.0 0.4 26244 3900 pts/0 Ss 14:41 0:00 -bash
raymond 10770 0.0 0.4 24120 3952 pts/0 S+ 16:49 0:00 -bash
root 10811 0.0 0.3 12724 2948 pts/1 S+ 16:55 0:00 /bin/bash ./test.sh
root 10816 0.0 0.1 12136 1140 pts/2 S+ 16:56 0:00 grep --color=auto bash
2.6 负载查询 uptime
/proc/uptime 包括两个值,单位 s
- 系统启动时长
- 空闲进程的总时长(按总的CPU核数计算)
uptime 和 w 显示以下内容
- 当前时间
- 系统已启动的时间
- 当前上线人数
- 系统平均负载(1、5、15分钟的平均负载,一般不会超过1,超过5时建议警报)
系统平均负载: 指在特定时间间隔内运行队列中的平均进程数,通常每个CPU内核的当前活动进程数不大于3,那么系统的性能良好。如果每个CPU内核的任务数大于5,那么此主机的性能有严重问题
如:linux主机是1个双核CPU,当Load Average 为6的时候说明机器已经被充分使用
范例:
[root@rocky8 ~]# cat /proc/uptime
14042.49 14304.52
[root@rocky8 ~]# echo 14042/60|bc
234
[root@rocky8 ~]# uptime
16:58:47 up 3:55, 3 users, load average: 0.06, 0.03, 0.18
2.7 显示CPU相关统计 mpstat
来自于sysstat包
范例:
[root@rocky8 ~]# mpstat
-bash: mpstat: command not found
[root@rocky8 ~]# dnf provides mpstat
Last metadata expiration check: 3:03:05 ago on Sun 31 Oct 2021 01:57:28 PM CST.
sysstat-11.7.3-5.el8.x86_64 : Collection of performance monitoring tools for Linux
Repo : AppStream
Matched from:
Filename : /usr/bin/mpstat
[root@rocky8 ~]# dnf -y install sysstat
[root@rocky8 ~]# mpstat
Linux 4.18.0-305.3.1.el8_4.x86_64 (rocky8) 10/31/2021 _x86_64_ (2 CPU)
05:01:01 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
05:01:01 PM all 7.54 0.01 26.73 0.01 0.27 1.07 0.00 0.00 0.00 64.37
#%usr 用户空间CPU占用多少 %nice 优先级 %sys 内核空间占用多少 %iowait IO等待 %irq 硬中断 %soft 软中断 %steal 被盗取时间(虚拟机) %guest 宾客(虚拟CPU) %gnice niceguset(虚拟机) %idle 空闲
[root@rocky8 ~]# mpstat 1 #一秒观察一次
Linux 4.18.0-305.3.1.el8_4.x86_64 (rocky8) 10/31/2021 _x86_64_ (2 CPU)
05:01:39 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
05:01:40 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:01:41 PM all 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 0.00 99.50
05:01:42 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:01:43 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:01:44 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:01:45 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:01:46 PM all 0.00 0.00 0.50 0.00 0.50 0.50 0.00 0.00 0.00 98.51
05:01:47 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:01:48 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
^C
Average: all 0.00 0.00 0.11 0.00 0.06 0.06 0.00 0.00 0.00 99.78
[root@rocky8 ~]# mpstat 1 3 #一秒观察一次,3次退出
Linux 4.18.0-305.3.1.el8_4.x86_64 (rocky8) 10/31/2021 _x86_64_ (2 CPU)
05:02:17 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle
05:02:18 PM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:02:19 PM all 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 0.00 99.50
05:02:20 PM all 0.00 0.00 0.00 0.00 0.00 0.50 0.00 0.00 0.00 99.50
Average: all 0.00 0.00 0.17 0.00 0.00 0.17 0.00 0.00 0.00 99.67
2.8 查看进程实时状态 top
top 提供动态的实时进程状态
有许多内置命令
帮助:h 或 ? ,按 q 或esc 退出帮助
排序:
P:以占据的CPU百分比,%CPU
M:占据内存百分比,%MEM
T:累积占据CPU时长,TIME+
首部信息显示:
uptime信息:l命令
tasks及cpu信息:t命令
cpu分别显示:1 (数字)
memory信息:m命令
退出命令:q
修改刷新时间间隔:s
终止指定进程:k
保存文件:W
top命令栏位信息简介
us:用户空间
sy:内核空间
ni:调整nice时间
id:空闲
wa:等待IO时间
hi:硬中断
si:软中断(模式切换)
st:虚拟机偷走的时间
top选项:
-d # 指定刷新时间间隔,默认为3秒
-b 全部显示所有进程
-n # 刷新多少次后退出
-H 线程模式
示例:
top -H -p `pidof mysqld`
范例:
[root@rocky8 ~]# top
top - 17:08:02 up 4:04, 3 users, load average: 0.01, 0.00, 0.08
Tasks: 159 total, 1 running, 157 sleeping, 1 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 782.4 total, 159.0 free, 209.1 used, 414.2 buff/cache
MiB Swap: 2048.0 total, 2047.7 free, 0.3 used. 441.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
767 root 20 0 414624 30068 14780 S 0.4 3.8 0:01.98 tuned
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.94 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
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.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-events_highpri
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
11 root 20 0 0 0 0 I 0.0 0.0 0:01.65 rcu_sched
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
13 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
17 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
#PR top 优先级 NI nice优先级 VIRT 虚拟内存 RES 实际物理内存 SHR 共享内存 S 状态 %CPU CPU利用率 %MEM 内存利用率 TIME+ 运行时间 COMMAND 命令
[root@rocky8 ~]# top
top - 17:08:49 up 4:05, 3 users, load average: 0.00, 0.00, 0.08
Tasks: 159 total, 1 running, 157 sleeping, 1 stopped, 0 zombie
%Cpu0 : 0.0 us, 0.0 sy, 0.0 ni, 99.6 id, 0.0 wa, 0.4 hi, 0.0 si, 0.0 st
%Cpu1 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 782.4 total, 159.3 free, 208.9 used, 414.2 buff/cache
MiB Swap: 2048.0 total, 2047.7 free, 0.3 used. 441.7 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.94 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
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.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-events_highpri
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
11 root 20 0 0 0 0 I 0.0 0.0 0:01.65 rcu_sched
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
13 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
17 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
#按1,显示多个CPU
[root@rocky8 ~]# top
Tasks: 159 total, 2 running, 156 sleeping, 1 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.7 hi, 0.0 si, 0.0 st
MiB Mem : 782.4 total, 159.5 free, 208.6 used, 414.2 buff/cache
MiB Swap: 2048.0 total, 2047.7 free, 0.3 used. 441.9 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11849 root 20 0 65428 4388 3752 R 1.4 0.5 0:00.01 top
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.94 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
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.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-events_highpri
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
11 root 20 0 0 0 0 I 0.0 0.0 0:01.66 rcu_sched
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
13 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
17 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
24 root 39 19 0 0 0 S 0.0 0.0 0:00.13 khugepaged
#l 隐藏uptime 显示的内容
[root@rocky8 ~]# top
top - 17:10:46 up 4:07, 3 users, load average: 0.00, 0.00, 0.07
Tasks: 158 total, 1 running, 156 sleeping, 1 stopped, 0 zombie
%Cpu0 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu1 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 782.4 total, 159.0 free, 209.1 used, 414.2 buff/cache
MiB Swap: 2048.0 total, 2047.7 free, 0.3 used. 441.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10188 root 20 0 153404 7084 5852 S 0.5 0.9 0:00.28 sshd
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.94 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
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.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-events_highpri
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
11 root 20 0 0 0 0 I 0.0 0.0 0:01.66 rcu_sched
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
13 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
17 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
#t 显示CPU使用率的不同风格
[root@rocky8 ~]# top
top - 17:11:44 up 4:07, 3 users, load average: 0.00, 0.00, 0.06
Tasks: 158 total, 2 running, 155 sleeping, 1 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.3 hi, 0.0 si, 0.0 st
MiB Mem : 43.5/782.4 [|||||||||||||||||||||||||||||||||||||||||||| ]
MiB Swap: 0.0/2048.0 [ ]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.95 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
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.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-events_highpri
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
11 root 20 0 0 0 0 I 0.0 0.0 0:01.67 rcu_sched
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
13 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
17 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
24 root 39 19 0 0 0 S 0.0 0.0 0:00.13 khugepaged
#m 显示内存使用率的不同风格
#k 可以杀死进程
[root@rocky8 ~]# top
top - 17:13:12 up 4:09, 3 users, load average: 0.00, 0.00, 0.05
Tasks: 157 total, 2 running, 154 sleeping, 1 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.4 sy, 0.0 ni, 99.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 782.4 total, 159.3 free, 208.8 used, 414.2 buff/cache
MiB Swap: 2048.0 total, 2047.7 free, 0.3 used. 441.7 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
809 root 20 0 227116 40756 39068 S 0.0 5.1 0:00.37 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
767 root 20 0 414624 30068 14780 S 0.0 3.8 0:02.00 /usr/libexec/platform-python -Es /usr/sbin/tuned -l -P
723 polkitd 20 0 1630348 24108 17076 S 0.0 3.0 0:00.12 /usr/lib/polkit-1/polkitd --no-debug
728 root 20 0 391536 18032 15772 S 0.0 2.3 0:00.36 /usr/sbin/NetworkManager --no-daemon
773 root 20 0 225680 14896 12124 S 0.0 1.9 0:00.28 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --lo+
721 root 20 0 216924 14128 12076 S 0.0 1.8 0:00.08 /usr/sbin/sssd -i --logger=files
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.95 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
718 root 20 0 86200 11220 9540 S 0.0 1.4 0:00.03 /usr/bin/VGAuthService -s
719 root 20 0 352128 10608 8872 S 0.0 1.3 0:12.87 /usr/bin/vmtoolsd
1302 root 20 0 100692 9904 8536 S 0.0 1.2 0:00.07 /usr/lib/systemd/systemd --user
635 root 20 0 124580 9872 7952 S 0.0 1.2 0:00.22 /usr/lib/systemd/systemd-udevd
601 root 20 0 97720 9372 8336 S 0.0 1.2 0:00.15 /usr/lib/systemd/systemd-journald
10449 root 20 0 139184 8808 7616 S 0.0 1.1 0:00.01 sshd: root [priv]
10481 root 20 0 139184 8740 7552 S 0.0 1.1 0:00.00 sshd: root [priv]
10186 root 20 0 139184 8668 7476 S 0.0 1.1 0:00.01 sshd: root [priv]
838 root 20 0 103976 8212 7208 S 0.0 1.0 0:00.06 /usr/lib/systemd/systemd-logind
765 root 20 0 94444 7972 7032 S 0.0 1.0 0:00.01 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@o+
10704 root 20 0 46888 7968 5172 T 0.0 1.0 0:00.00 vim anaconda-ks.cfg
10188 root 20 0 153404 7084 5852 S 0.0 0.9 0:00.33 sshd: root@pts/2
10451 root 20 0 153404 7068 5836 S 0.0 0.9 0:30.51 sshd: root@pts/1
#默认以CPU使用率排序,按M以内存使用率排序
[root@rocky8 ~]# top
top - 17:13:51 up 4:10, 3 users, load average: 0.00, 0.00, 0.05
Tasks: 157 total, 1 running, 155 sleeping, 1 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 782.4 total, 159.1 free, 209.1 used, 414.2 buff/cache
MiB Swap: 2048.0 total, 2047.7 free, 0.3 used. 441.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
719 root 20 0 352128 10608 8872 S 0.3 1.3 0:12.90 vmtoolsd
1 root 20 0 184004 11740 8964 S 0.0 1.5 0:01.95 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
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.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-events_highpri
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
10 root 20 0 0 0 0 S 0.0 0.0 0:00.23 ksoftirqd/0
11 root 20 0 0 0 0 I 0.0 0.0 0:01.69 rcu_sched
12 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
13 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
17 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 netns
18 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kauditd
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khungtaskd
20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 oom_reaper
21 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 writeback
22 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kcompactd0
23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
#按P 以CPU使用率排序
[root@rocky8 ~]# dnf -y install mysql-server
[root@rocky8 ~]# systemctl enable --now mysqld
[root@rocky8 ~]# top -H -p `pidof mysqld`
top - 17:24:12 up 4:20, 3 users, load average: 0.11, 0.08, 0.06
Threads: 37 total, 0 running, 37 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.2 sy, 0.0 ni, 99.5 id, 0.0 wa, 0.2 hi, 0.2 si, 0.0 st
MiB Mem : 782.4 total, 55.2 free, 526.5 used, 200.7 buff/cache
MiB Swap: 2048.0 total, 2034.6 free, 13.4 used. 136.8 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14755 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.32 mysqld
14759 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14760 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14761 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.01 mysqld
14762 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14763 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.01 mysqld
14764 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14765 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14766 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14767 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14768 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14769 mysql 0 -20 1774332 385244 35728 S 0.0 48.1 0:00.01 mysqld
14770 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.01 mysqld
14771 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.05 mysqld
14772 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.05 mysqld
14773 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.06 mysqld
14774 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.05 mysqld
14777 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
14778 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.01 mysqld
14779 mysql 20 0 1774332 385244 35728 S 0.0 48.1 0:00.00 mysqld
#指定进程的相关信息,-H 显示线程
htop命令:增强版的TOP命令,来自EPEL源,比top功能更强
[root@rocky8 ~]# htop
-bash: htop: command not found
[root@rocky8 ~]# dnf provides htop
Last metadata expiration check: 3:08:23 ago on Sun 31 Oct 2021 01:57:28 PM CST.
htop-3.0.5-1.el8.x86_64 : Interactive process viewer
Repo : epel
Matched from:
Provide : htop = 3.0.5-1.el8
[root@rocky8 ~]# dnf -y install htop
[root@rocky8 ~]# htop
选项:
-d #: 指定延迟时间;
-u UserName: 仅显示指定用户的进程
-s COLUME: 以指定字段进行排序
子命令:
s:跟踪选定进程的系统调用
l:显示选定进程打开的文件列表
a:将选定的进程绑定至某指定CPU核心
t:显示进程树
2.9 内存空间free
free 可以显示内存空间使用状态
格式:
free [OPTION]
常用选项:
-b 以字节为单位
-m 以MB为单位
-g 以GB为单位
-h 易读格式
-o 不显示-/+buffers/cache行
-t 显示RAM + swap的总和
-s n 刷新间隔为n秒
-c n 刷新n次后即退出
范例:
[root@rocky8 ~]# free
total used free shared buff/cache available
Mem: 801164 539276 58688 872 203200 140668
Swap: 2097148 13740 2083408
[root@rocky8 ~]# free -h
total used free shared buff/cache available
Mem: 782Mi 526Mi 57Mi 0.0Ki 198Mi 137Mi
Swap: 2.0Gi 13Mi 2.0Gi
[root@centos6 ~]# free -h
total used free shared buffers cached
Mem: 979M 312M 666M 240K 14M 212M
-/+ buffers/cache: 86M 893M
Swap: 2.0G 0B 2.0G
[root@rocky8 ~]# free -h -s 3 -c 5 #-s 3 每3秒刷新一次 -c 5 刷新5次
total used free shared buff/cache available
Mem: 782Mi 526Mi 57Mi 0.0Ki 198Mi 137Mi
Swap: 2.0Gi 13Mi 2.0Gi
total used free shared buff/cache available
Mem: 782Mi 526Mi 57Mi 0.0Ki 198Mi 137Mi
Swap: 2.0Gi 13Mi 2.0Gi
total used free shared buff/cache available
Mem: 782Mi 526Mi 57Mi 0.0Ki 198Mi 137Mi
Swap: 2.0Gi 13Mi 2.0Gi
total used free shared buff/cache available
Mem: 782Mi 525Mi 58Mi 0.0Ki 198Mi 138Mi
Swap: 2.0Gi 13Mi 2.0Gi
total used free shared buff/cache available
Mem: 782Mi 525Mi 58Mi 0.0Ki 198Mi 138Mi
Swap: 2.0Gi 13Mi 2.0Gi
[root@rocky8 ~]# echo 3 > /proc/sys/vm/drop_caches #清空buff/cache
[root@rocky8 ~]# free -h
total used free shared buff/cache available
Mem: 782Mi 523Mi 164Mi 0.0Ki 94Mi 152Mi
Swap: 2.0Gi 13Mi 2.0Gi
标签:03,00,第十一章,50,0.0,进程,irq,root,13 来源: https://blog.csdn.net/qq_25599925/article/details/121072398