当前位置: 首页 > news >正文

Linux84 SHELL编程:流程控制 前瞻(1)

问题

ping -c1 $IP &&> /dev/null

Breakdown:​​

ping -c1 “$IP”: Sends a single ICMP packet to the specified IP address

/dev/null: Silences standard output (normal ping responses)
2>&1: Redirects error messages (stderr) to stdout, silencing errors too
“$IP”: Quotes protect against spaces/special characters in IP variables

if [ $# -ne 1];thenecho "Usage:$0 remote_ip" $$ exit
fi

Key Corrections:​​

​​Space before bracket​​ (critical): Added space after 1in [ $# -ne 1 ]→ Shell requires spaces around brackets
​​Removed extra $​​: Changed $$ exitto exit 1(proper error exit)
​​Added space in usage message​​: Better formatting with Usage: $0
​​Explanation:​​

$# -ne 1checks if argument count is not equal to 1
exit 1returns error status (non-zero = failure) to the calling process
Double wasincorrectlyused−expandstocurrentprocessPIDRemovedunnecessarywas incorrectly used - expands to current process PID Removed unnecessary wasincorrectlyusedexpandstocurrentprocessPIDRemovedunnecessaryto avoid incorrect PID printing
​​Best Practices Added:​​

​​Quoting variables​​: Better to quote variables (“$0”) for edge cases
​​Explicit error codes​​: Clear exit code (1= general error)
​​Usage clarity​​: Standard format for usage messages
在这里插入图片描述
在这里插入图片描述

if [ $# -ne 1 ];thenecho "Usage:$0 remote_ip" $$ exit
fi
ping -c1 &1 $> /dev/null
[ $? -eq 0] && echo "当前主机可以ping通远程主机$1" ||echo "当前主机Ping不通远程主机$1"
~

在这里插入图片描述
在这里插入图片描述
-eq
-ne
[ $# -ne 1 ]:检查参数数量是否为1
在这里插入图片描述
在这里插入图片描述

[root@web ~]# ./ping2.sh
Usage:./ping2.sh remote_ip 41465 exit
ping: $: 未知的名称或服务
当前主机Ping不通远程主机

在这里插入图片描述


[root@web ~]# echo "Usage:$0"
Usage:-bash
您在 /var/spool/mail/root 中有邮件

在这里插入图片描述

在这里插入图片描述
shell中usage 用法
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[root@web ~]# echo "Usage:$0 remote_ip"
Usage:-bash remote_ip
您在 /var/spool/mail/root 中有邮件

在这里插入图片描述
在这里插入图片描述

 echo "Usage:$0 remote_ip" >&2

在这里插入图片描述

[root@web ~]# cat ping2.sh
#!/bin/bash
# Name:ping2.sh
# Path:/root
# Usage:/root/ping2.sh
if [ $# -ne 1 ];thenecho "Usage:$0 remote_ip" >&2exit
fi
ping -c1 $1 $> /dev/null
[ $? -eq 0 ] && echo "当前主机可以ping通远程主机$1" ||echo "当前主机Ping不通远程主机$1"
[root@web ~]# ./ping2.sh
Usage:./ping2.sh remote_ip
您在 /var/spool/mail/root 中有邮件
[root@web ~]#

在这里插入图片描述
在这里插入图片描述


[root@web ~]# pidof

在这里插入图片描述


pgrep $process &> /dev/null

在这里插入图片描述
在这里插入图片描述

#!/bin/bash
wget http://10.1.1.2 &>/dev/null
[ $? -eq 0 ] && echo "该web服务正常" && rm -f /root/index.* || echo "该web服务异常"

在这里插入图片描述

记录

root@192.168.235.20's password:┌────────────────────────────────────────────────────────────────────┐│                        • MobaXterm 20.0 •                          ││            (SSH client, X-server and networking tools)             ││                                                                    ││ ➤ SSH session to root@192.168.235.20                               ││   • SSH compression : ✘                                            ││   • SSH-browser     : ✔                                            ││   • X11-forwarding  : ✔  (remote display is forwarded through SSH) ││   • DISPLAY         : ✔  (automatically set on remote server)      ││                                                                    ││ ➤ For more info, ctrl+click on help or visit our website           │└────────────────────────────────────────────────────────────────────┘Last login: Sun Aug  3 20:32:09 2025 from 192.168.235.1
[root@web ~]# vim ping.sh
您在 /var/spool/mail/root 中有新邮件
[root@web ~]# cat ping.sh
#!/bin/bash
# Name:ping.sh
# Path:/shell02/
# Usage:/shell02/ping.sh
read -p "要Ping的远程主机ip:" IP
ping -c1 $IP &> /dev/null
if [$? -eq 0];thenecho "当前主机可以ping通远程$IP"
elseecho "当前主机ping不同远程$IP"
fi
[root@web ~]# pwd
/root
[root@web ~]# chmod +x ping.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./ping.sh
要Ping的远程主机ip:192.168.235.9
./ping.sh:行7: [1: 未找到命令
当前主机ping不同远程192.168.235.9
[root@web ~]# vim ping2.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# chmod ping2.sh
chmod: "ping2.sh" 后缺少操作数
Try 'chmod --help' for more information.
[root@web ~]# chmod +X ping2.sh
[root@web ~]# ./ping2.sh
-bash: ./ping2.sh: 权限不够
[root@web ~]# ls ping2.sh
ping2.sh
[root@web ~]# ll ping2.sh
-rw-r--r-- 1 root root 264 8月   4 20:58 ping2.sh
[root@web ~]# chmod +x ping2.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./ping2.sh
Usage:./ping2.sh remote_ip 41465 exit
ping: $: 未知的名称或服务
当前主机Ping不通远程主机
[root@web ~]# cat ping2.sh
#!/bin/bash
# Name:ping2.sh
# Path:/root
# Usage:/root/ping2.sh
if [ $# -ne 1 ];thenecho "Usage:$0 remote_ip" $$ exit
fi
ping -c1 $1 $> /dev/null
[ $? -eq 0 ] && echo "当前主机可以ping通远程主机$1" ||echo "当前主机Ping不通远程主机$1"
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim ping2.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# echo "Usage:$0 remote_ip"
Usage:-bash remote_ip
您在 /var/spool/mail/root 中有邮件
[root@web ~]# echo "Usage:$0"
Usage:-bash
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim ping2.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat ping2.sh
#!/bin/bash
# Name:ping2.sh
# Path:/root
# Usage:/root/ping2.sh
if [ $# -ne 1 ];thenecho "Usage:$0 remote_ip" >&2exit
fi
ping -c1 $1 $> /dev/null
[ $? -eq 0 ] && echo "当前主机可以ping通远程主机$1" ||echo "当前主机Ping不通远程主机$1"
[root@web ~]# ./ping2.sh
Usage:./ping2.sh remote_ip
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./ping2.sh 192.168.235.2
ping: $: 未知的名称或服务
当前主机Ping不通远程主机192.168.235.2
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim ping2.sh
[root@web ~]# cat ping2.sh
#!/bin/bash
# Name:ping2.sh
# Path:/root
# Usage:/root/ping2.sh
if [ $# -ne 1 ];thenecho "Usage:$0 remote_ip" >&2exit 1
fi
ping -c1 $1 &> /dev/null
[ $? -eq 0 ] && echo "当前主机可以ping通远程主机$1" ||echo "当前主机Ping不通远程主机$1"
[root@web ~]# ./ping2.sh 192.168.235.2
当前主机可以ping通远程主机192.168.235.2
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ping 192.168.235.2
PING 192.168.235.2 (192.168.235.2) 56(84) bytes of data.
64 bytes from 192.168.235.2: icmp_seq=1 ttl=128 time=0.086 ms
64 bytes from 192.168.235.2: icmp_seq=2 ttl=128 time=0.125 ms
64 bytes from 192.168.235.2: icmp_seq=3 ttl=128 time=0.131 ms
^C
--- 192.168.235.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.086/0.114/0.131/0.019 ms
[root@web ~]# ps -ef pgrep
error: process ID list syntax errorUsage:ps [options]Try 'ps --help <simple|list|output|threads|misc|all>'or 'ps --help <s|l|o|t|m|a>'for additional help text.For more details see ps(1).
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 19:16 ?        00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root          2      0  0 19:16 ?        00:00:00 [kthreadd]
root          4      2  0 19:16 ?        00:00:00 [kworker/0:0H]
root          6      2  0 19:16 ?        00:00:00 [ksoftirqd/0]
root          7      2  0 19:16 ?        00:00:00 [migration/0]
root          8      2  0 19:16 ?        00:00:00 [rcu_bh]
root          9      2  0 19:16 ?        00:00:01 [rcu_sched]
root         10      2  0 19:16 ?        00:00:00 [lru-add-drain]
root         11      2  0 19:16 ?        00:00:00 [watchdog/0]
root         12      2  0 19:16 ?        00:00:00 [watchdog/1]
root         13      2  0 19:16 ?        00:00:00 [migration/1]
root         14      2  0 19:16 ?        00:00:00 [ksoftirqd/1]
root         16      2  0 19:16 ?        00:00:00 [kworker/1:0H]
root         18      2  0 19:16 ?        00:00:00 [kdevtmpfs]
root         19      2  0 19:16 ?        00:00:00 [netns]
root         20      2  0 19:16 ?        00:00:00 [khungtaskd]
root         21      2  0 19:16 ?        00:00:00 [writeback]
root         22      2  0 19:16 ?        00:00:00 [kintegrityd]
root         23      2  0 19:16 ?        00:00:00 [bioset]
root         24      2  0 19:16 ?        00:00:00 [bioset]
root         25      2  0 19:16 ?        00:00:00 [bioset]
root         26      2  0 19:16 ?        00:00:00 [kblockd]
root         27      2  0 19:16 ?        00:00:00 [md]
root         28      2  0 19:16 ?        00:00:00 [edac-poller]
root         29      2  0 19:16 ?        00:00:00 [watchdogd]
root         35      2  0 19:16 ?        00:00:00 [kswapd0]
root         36      2  0 19:16 ?        00:00:00 [ksmd]
root         37      2  0 19:16 ?        00:00:00 [khugepaged]
root         38      2  0 19:16 ?        00:00:00 [crypto]
root         46      2  0 19:16 ?        00:00:00 [kthrotld]
root         48      2  0 19:16 ?        00:00:00 [kmpath_rdacd]
root         49      2  0 19:16 ?        00:00:00 [kaluad]
root         50      2  0 19:16 ?        00:00:02 [kworker/0:1]
root         51      2  0 19:16 ?        00:00:00 [kpsmoused]
root         52      2  0 19:16 ?        00:00:00 [kworker/0:2]
root         53      2  0 19:16 ?        00:00:00 [ipv6_addrconf]
root         66      2  0 19:16 ?        00:00:00 [deferwq]
root        109      2  0 19:16 ?        00:00:00 [kauditd]
root        287      2  0 19:16 ?        00:00:00 [nfit]
root        288      2  0 19:16 ?        00:00:00 [ata_sff]
root        289      2  0 19:16 ?        00:00:00 [scsi_eh_0]
root        290      2  0 19:16 ?        00:00:00 [scsi_tmf_0]
root        291      2  0 19:16 ?        00:00:00 [scsi_eh_1]
root        292      2  0 19:16 ?        00:00:00 [scsi_tmf_1]
root        295      2  0 19:16 ?        00:00:00 [mpt_poll_0]
root        296      2  0 19:16 ?        00:00:00 [mpt/0]
root        304      2  0 19:16 ?        00:00:00 [scsi_eh_2]
root        305      2  0 19:16 ?        00:00:00 [scsi_tmf_2]
root        307      2  0 19:16 ?        00:00:00 [irq/16-vmwgfx]
root        308      2  0 19:16 ?        00:00:00 [ttm_swap]
root        777      2  0 19:16 ?        00:00:00 [kdmflush]
root        778      2  0 19:16 ?        00:00:00 [bioset]
root        789      2  0 19:16 ?        00:00:00 [kdmflush]
root        790      2  0 19:16 ?        00:00:00 [bioset]
root        802      2  0 19:16 ?        00:00:00 [bioset]
root        803      2  0 19:16 ?        00:00:00 [xfsalloc]
root        804      2  0 19:16 ?        00:00:00 [xfs_mru_cache]
root        805      2  0 19:16 ?        00:00:00 [xfs-buf/dm-0]
root        806      2  0 19:16 ?        00:00:00 [xfs-data/dm-0]
root        807      2  0 19:16 ?        00:00:00 [xfs-conv/dm-0]
root        808      2  0 19:16 ?        00:00:00 [xfs-cil/dm-0]
root        809      2  0 19:16 ?        00:00:00 [xfs-reclaim/dm-]
root        810      2  0 19:16 ?        00:00:00 [xfs-log/dm-0]
root        811      2  0 19:16 ?        00:00:00 [xfs-eofblocks/d]
root        812      2  0 19:16 ?        00:00:02 [xfsaild/dm-0]
root        813      2  0 19:16 ?        00:00:00 [kworker/1:1H]
root        904      1  0 19:16 ?        00:00:00 /usr/lib/systemd/systemd-journald
root        928      1  0 19:16 ?        00:00:00 /usr/sbin/lvmetad -f
root        934      1  0 19:16 ?        00:00:00 /usr/lib/systemd/systemd-udevd
root       1019      2  0 19:16 ?        00:00:00 [bioset]
root       1024      2  0 19:16 ?        00:00:00 [bioset]
root       1118      2  0 19:16 ?        00:00:00 [xfs-buf/sda1]
root       1119      2  0 19:16 ?        00:00:00 [xfs-data/sda1]
root       1120      2  0 19:16 ?        00:00:00 [xfs-conv/sda1]
root       1121      2  0 19:16 ?        00:00:00 [xfs-cil/sda1]
root       1122      2  0 19:16 ?        00:00:00 [xfs-reclaim/sda]
root       1123      2  0 19:16 ?        00:00:00 [xfs-log/sda1]
root       1124      2  0 19:16 ?        00:00:00 [xfs-eofblocks/s]
root       1125      2  0 19:16 ?        00:00:00 [xfsaild/sda1]
root       1128      2  0 19:16 ?        00:00:00 [jbd2/sdb2-8]
root       1129      2  0 19:16 ?        00:00:00 [ext4-rsv-conver]
root       1135      2  0 19:16 ?        00:00:00 [kdmflush]
root       1136      2  0 19:16 ?        00:00:00 [bioset]
root       1141      2  0 19:16 ?        00:00:00 [kdmflush]
root       1142      2  0 19:16 ?        00:00:00 [bioset]
root       1144      2  0 19:16 ?        00:00:00 [kdmflush]
root       1145      2  0 19:16 ?        00:00:00 [bioset]
root       1146      2  0 19:16 ?        00:00:00 [kdmflush]
root       1148      2  0 19:16 ?        00:00:00 [bioset]
root       1157      2  0 19:16 ?        00:00:00 [kdmflush]
root       1158      2  0 19:16 ?        00:00:00 [bioset]
root       1164      2  0 19:16 ?        00:00:00 [kdmflush]
root       1165      2  0 19:16 ?        00:00:00 [bioset]
root       1171      2  0 19:16 ?        00:00:00 [kdmflush]
root       1172      2  0 19:16 ?        00:00:00 [kdmflush]
root       1173      2  0 19:16 ?        00:00:00 [bioset]
root       1174      2  0 19:16 ?        00:00:00 [bioset]
root       1176      2  0 19:16 ?        00:00:00 [kdmflush]
root       1178      2  0 19:16 ?        00:00:00 [bioset]
root       1187      2  0 19:16 ?        00:00:00 [jbd2/dm-8-8]
root       1188      2  0 19:16 ?        00:00:00 [ext4-rsv-conver]
root       1193      2  0 19:16 ?        00:00:00 [raid5wq]
root       1195      2  0 19:16 ?        00:00:00 [dm_bufio_cache]
root       1196      2  0 19:16 ?        00:00:00 [kdmflush]
root       1197      2  0 19:16 ?        00:00:00 [bioset]
root       1198      2  0 19:16 ?        00:00:00 [kdmflush]
root       1199      2  0 19:16 ?        00:00:00 [bioset]
root       1200      2  0 19:16 ?        00:00:00 [kdmflush]
root       1203      2  0 19:16 ?        00:00:00 [bioset]
root       1204      2  0 19:16 ?        00:00:00 [kdmflush]
root       1208      2  0 19:16 ?        00:00:00 [bioset]
root       1212      2  0 19:16 ?        00:00:00 [kdmflush]
root       1219      2  0 19:16 ?        00:00:00 [bioset]
root       1220      2  0 19:16 ?        00:00:00 [bioset]
root       1221      2  0 19:16 ?        00:00:00 [mdX_raid1]
root       1222      2  0 19:16 ?        00:00:00 [bioset]
root       1223      2  0 19:16 ?        00:00:00 [kdmflush]
root       1224      2  0 19:16 ?        00:00:00 [bioset]
root       1225      2  0 19:16 ?        00:00:00 [kdmflush]
root       1226      2  0 19:16 ?        00:00:00 [bioset]
root       1227      2  0 19:16 ?        00:00:00 [kdmflush]
root       1228      2  0 19:16 ?        00:00:00 [ksnaphd]
root       1229      2  0 19:16 ?        00:00:00 [kcopyd]
root       1231      2  0 19:16 ?        00:00:00 [bioset]
root       1232      2  0 19:16 ?        00:00:00 [bioset]
root       1234      2  0 19:16 ?        00:00:00 [bioset]
root       1239      1  0 19:16 ?        00:00:00 /usr/sbin/dmeventd -f
root       1291      1  0 19:16 ?        00:00:00 /sbin/auditd
root       1293   1291  0 19:16 ?        00:00:00 /sbin/audispd
root       1295   1293  0 19:16 ?        00:00:00 /usr/sbin/sedispatch
root       1297      2  0 19:16 ?        00:00:00 [rpciod]
root       1298      2  0 19:16 ?        00:00:00 [xprtiod]
rpc        1322      1  0 19:16 ?        00:00:00 /sbin/rpcbind -w
root       1323      1  0 19:16 ?        00:00:00 /usr/sbin/abrtd -d -s
root       1324      1  0 19:16 ?        00:00:00 /usr/bin/abrt-watch-log -F BUG: WARNING: at WARNING: CPU: INFO: possible recursive locking detected e
root       1325      1  0 19:16 ?        00:00:00 /usr/sbin/ModemManager
root       1327      1  0 19:16 ?        00:00:00 /usr/sbin/smartd -n -q never
root       1328      1  0 19:16 ?        00:00:00 /usr/bin/VGAuthService -s
root       1329      1  0 19:16 ?        00:00:10 /usr/bin/vmtoolsd
root       1330      1  0 19:16 ?        00:00:00 /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00
root       1335      1  0 19:16 ?        00:00:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/Xorg.0.log -- /usr/bin/abrt-dump-xorg -xD
root       1338      1  0 19:16 ?        00:00:00 /usr/sbin/irqbalance --foreground
polkitd    1339      1  0 19:16 ?        00:00:05 /usr/lib/polkit-1/polkitd --no-debug
root       1340      1  0 19:16 ?        00:00:00 /sbin/rngd -f
avahi      1342      1  0 19:16 ?        00:00:00 avahi-daemon: running [web.local]
rtkit      1346      1  0 19:16 ?        00:00:00 /usr/libexec/rtkit-daemon
libstor+   1347      1  0 19:16 ?        00:00:00 /usr/bin/lsmd -d
root       1351      1  0 19:16 ?        00:00:00 /usr/libexec/udisks2/udisksd
root       1354      1  0 19:16 ?        00:00:00 /usr/libexec/accounts-daemon
dbus       1355      1  0 19:16 ?        00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       1360      1  0 19:16 ?        00:00:00 /usr/sbin/gssproxy -D
avahi      1369   1342  0 19:16 ?        00:00:00 avahi-daemon: chroot helper
chrony     1370      1  0 19:16 ?        00:00:00 /usr/sbin/chronyd
root       1401      1  0 19:16 ?        00:00:00 /usr/lib/systemd/systemd-logind
root       1421      1  0 19:16 ?        00:00:00 /bin/bash /usr/sbin/ksmtuned
root       1436      2  0 19:16 ?        00:00:00 [kworker/0:1H]
root       1717      1  0 19:16 ?        00:00:00 /usr/sbin/sshd -D
root       1718      1  0 19:16 ?        00:00:00 /usr/sbin/cupsd -f
root       1721      1  0 19:16 ?        00:00:00 /usr/sbin/rsyslogd -n
root       1722      1  0 19:16 ?        00:00:00 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
root       1731      1  0 19:16 ?        00:00:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
root       1732      1  0 19:16 ?        00:00:04 /usr/sbin/libvirtd
root       1735      1  0 19:16 ?        00:00:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root       1739      1  0 19:16 ?        00:00:00 /usr/sbin/atd -f
root       1740      1  0 19:16 ?        00:00:00 /usr/sbin/crond -n
root       1771      2  0 19:16 ?        00:00:00 [jbd2/dm-7-8]
root       1772      2  0 19:16 ?        00:00:00 [ext4-rsv-conver]
root       1780      2  0 19:16 ?        00:00:00 [jbd2/dm-2-8]
root       1781      2  0 19:16 ?        00:00:00 [ext4-rsv-conver]
root       1785      1  0 19:16 ?        00:00:00 /usr/sbin/gdm
root       1954      1  0 19:16 ?        00:00:00 /usr/libexec/postfix/master -w
postfix    1956   1954  0 19:16 ?        00:00:00 qmgr -l -t unix -u
nobody     2020      1  0 19:16 ?        00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr
root       2021   2020  0 19:16 ?        00:00:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr
root       2101   1785  0 19:16 tty1     00:00:00 /usr/bin/X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-trTm23/database
root       2114   1785  0 19:16 ?        00:00:00 gdm-session-worker [pam/gdm-launch-environment]
gdm        2118   2114  0 19:16 ?        00:00:00 /usr/libexec/gnome-session-binary --autostart /usr/share/gdm/greeter/autostart
gdm        2123      1  0 19:16 ?        00:00:00 dbus-launch --exit-with-session /usr/libexec/gnome-session-binary --autostart /usr/share/gdm/greeter/
gdm        2124      1  0 19:16 ?        00:00:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
gdm        2129      1  0 19:16 ?        00:00:00 /usr/libexec/at-spi-bus-launcher
gdm        2134   2129  0 19:16 ?        00:00:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-ad
gdm        2136      1  0 19:16 ?        00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
gdm        2161   2118  0 19:16 ?        00:00:03 /usr/bin/gnome-shell
root       2169      1  0 19:16 ?        00:00:00 /usr/libexec/upowerd
gdm        2186      1  0 19:16 ?        00:00:00 /usr/bin/pulseaudio --start --log-target=syslog
gdm        2205   2161  0 19:16 ?        00:00:00 ibus-daemon --xim --panel disable
gdm        2208   2205  0 19:16 ?        00:00:00 /usr/libexec/ibus-dconf
gdm        2211      1  0 19:16 ?        00:00:00 /usr/libexec/ibus-x11 --kill-daemon
gdm        2216      1  0 19:16 ?        00:00:00 /usr/libexec/ibus-portal
gdm        2224      1  0 19:16 ?        00:00:00 /usr/libexec/xdg-permission-store
root       2232      1  0 19:16 ?        00:00:00 /usr/libexec/boltd
root       2236      1  0 19:16 ?        00:00:00 /usr/sbin/wpa_supplicant -u -f /var/log/wpa_supplicant.log -c /etc/wpa_supplicant/wpa_supplicant.conf
root       2242      1  0 19:16 ?        00:00:00 /usr/libexec/packagekitd
gdm        2248   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-xsettings
gdm        2249   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-a11y-settings
gdm        2251   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-clipboard
gdm        2254   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-color
gdm        2259   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-datetime
gdm        2260   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-housekeeping
gdm        2263   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-keyboard
gdm        2266   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-media-keys
gdm        2275   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-mouse
gdm        2276   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-power
gdm        2279   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-print-notifications
gdm        2283   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-rfkill
gdm        2289   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-screensaver-proxy
gdm        2294   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-sharing
gdm        2299   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-smartcard
gdm        2306   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-sound
gdm        2309   2118  0 19:16 ?        00:00:00 /usr/libexec/gsd-wacom
colord     2326      1  0 19:16 ?        00:00:00 /usr/libexec/colord
gdm        2349   2205  0 19:16 ?        00:00:00 /usr/libexec/ibus-engine-simple
root       2439   1717  0 19:18 ?        00:00:07 sshd: root@pts/0
root       2463   1717  0 19:19 ?        00:00:00 sshd: root@notty
root       2473   2463  0 19:19 ?        00:00:00 /usr/libexec/openssh/sftp-server
root       2481   2439  0 19:19 pts/0    00:00:00 -bash
root       2523   2439  0 19:19 ?        00:00:08 bash -c while [ -d /proc/$PPID ]; do sleep 1;head -v -n 8 /proc/meminfo; head -v -n 2 /proc/stat /pro
root       3498      2  0 19:21 ?        00:00:00 [kworker/0:0]
root      22267      2  0 20:10 ?        00:00:00 [kworker/u256:0]
postfix   40487   1954  0 20:56 ?        00:00:00 pickup -l -t unix -u
postfix   40519   1954  0 20:57 ?        00:00:00 cleanup -z -t unix -u
postfix   40522   1954  0 20:57 ?        00:00:00 trivial-rewrite -n rewrite -t unix -u
postfix   49072   1954  0 21:19 ?        00:00:00 local -t unix
postfix   49867   1954  0 21:21 ?        00:00:00 bounce -z -t unix -u
root      52347      2  0 21:27 ?        00:00:00 [kworker/1:2]
root      54489      2  0 21:33 ?        00:00:00 [kworker/1:0]
root      54505      2  0 21:33 ?        00:00:00 [kworker/u256:2]
root      57995      2  0 21:42 ?        00:00:00 [kworker/u256:1]
root      58380      2  0 21:43 ?        00:00:00 [kworker/1:1]
root      59042   1421  0 21:44 ?        00:00:00 sleep 60
root      59393   2523  0 21:45 ?        00:00:00 sleep 1
root      59394   2481  0 21:45 pts/0    00:00:00 ps -ef
[root@web ~]# pgrep
pgrep: no matching criteria specified
Try `pgrep --help' for more information.
[root@web ~]# ps auxf pidof
error: process ID list syntax errorUsage:ps [options]Try 'ps --help <simple|list|output|threads|misc|all>'or 'ps --help <s|l|o|t|m|a>'for additional help text.For more details see ps(1).
[root@web ~]# ps auxf
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          2  0.0  0.0      0     0 ?        S    19:16   0:00 [kthreadd]
root          4  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kworker/0:0H]
root          6  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [ksoftirqd/0]
root          7  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [migration/0]
root          8  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [rcu_bh]
root          9  0.0  0.0      0     0 ?        S    19:16   0:01  \_ [rcu_sched]
root         10  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [lru-add-drain]
root         11  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [watchdog/0]
root         12  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [watchdog/1]
root         13  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [migration/1]
root         14  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [ksoftirqd/1]
root         16  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kworker/1:0H]
root         18  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [kdevtmpfs]
root         19  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [netns]
root         20  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [khungtaskd]
root         21  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [writeback]
root         22  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kintegrityd]
root         23  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root         24  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root         25  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root         26  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kblockd]
root         27  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [md]
root         28  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [edac-poller]
root         29  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [watchdogd]
root         35  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [kswapd0]
root         36  0.0  0.0      0     0 ?        SN   19:16   0:00  \_ [ksmd]
root         37  0.0  0.0      0     0 ?        SN   19:16   0:00  \_ [khugepaged]
root         38  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [crypto]
root         46  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kthrotld]
root         48  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kmpath_rdacd]
root         49  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kaluad]
root         50  0.0  0.0      0     0 ?        S    19:16   0:02  \_ [kworker/0:1]
root         51  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kpsmoused]
root         52  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [kworker/0:2]
root         53  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ipv6_addrconf]
root         66  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [deferwq]
root        109  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [kauditd]
root        287  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [nfit]
root        288  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ata_sff]
root        289  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [scsi_eh_0]
root        290  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [scsi_tmf_0]
root        291  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [scsi_eh_1]
root        292  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [scsi_tmf_1]
root        295  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [mpt_poll_0]
root        296  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [mpt/0]
root        304  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [scsi_eh_2]
root        305  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [scsi_tmf_2]
root        307  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [irq/16-vmwgfx]
root        308  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ttm_swap]
root        777  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root        778  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root        789  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root        790  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root        802  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root        803  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfsalloc]
root        804  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs_mru_cache]
root        805  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-buf/dm-0]
root        806  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-data/dm-0]
root        807  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-conv/dm-0]
root        808  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-cil/dm-0]
root        809  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-reclaim/dm-]
root        810  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-log/dm-0]
root        811  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-eofblocks/d]
root        812  0.0  0.0      0     0 ?        S    19:16   0:02  \_ [xfsaild/dm-0]
root        813  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kworker/1:1H]
root       1019  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1024  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1118  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-buf/sda1]
root       1119  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-data/sda1]
root       1120  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-conv/sda1]
root       1121  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-cil/sda1]
root       1122  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-reclaim/sda]
root       1123  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-log/sda1]
root       1124  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xfs-eofblocks/s]
root       1125  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [xfsaild/sda1]
root       1128  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [jbd2/sdb2-8]
root       1129  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ext4-rsv-conver]
root       1135  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1136  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1141  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1142  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1144  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1145  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1146  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1148  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1157  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1158  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1164  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1165  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1171  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1172  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1173  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1174  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1176  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1178  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1187  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [jbd2/dm-8-8]
root       1188  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ext4-rsv-conver]
root       1193  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [raid5wq]
root       1195  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [dm_bufio_cache]
root       1196  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1197  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1198  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1199  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1200  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1203  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1204  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1208  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1212  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1219  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1220  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1221  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [mdX_raid1]
root       1222  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1223  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1224  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1225  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1226  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1227  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kdmflush]
root       1228  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ksnaphd]
root       1229  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kcopyd]
root       1231  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1232  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1234  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [bioset]
root       1297  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [rpciod]
root       1298  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [xprtiod]
root       1436  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [kworker/0:1H]
root       1771  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [jbd2/dm-7-8]
root       1772  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ext4-rsv-conver]
root       1780  0.0  0.0      0     0 ?        S    19:16   0:00  \_ [jbd2/dm-2-8]
root       1781  0.0  0.0      0     0 ?        S<   19:16   0:00  \_ [ext4-rsv-conver]
root       3498  0.0  0.0      0     0 ?        S    19:21   0:00  \_ [kworker/0:0]
root      22267  0.0  0.0      0     0 ?        S    20:10   0:00  \_ [kworker/u256:0]
root      52347  0.0  0.0      0     0 ?        S    21:27   0:00  \_ [kworker/1:2]
root      54489  0.0  0.0      0     0 ?        S    21:33   0:00  \_ [kworker/1:0]
root      54505  0.0  0.0      0     0 ?        S    21:33   0:00  \_ [kworker/u256:2]
root      57995  0.0  0.0      0     0 ?        S    21:42   0:00  \_ [kworker/u256:1]
root      58380  0.0  0.0      0     0 ?        S    21:43   0:00  \_ [kworker/1:1]
root          1  0.0  0.4 126160  4576 ?        Ss   19:16   0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root        904  0.0  0.2  37344  2588 ?        Ss   19:16   0:00 /usr/lib/systemd/systemd-journald
root        928  0.0  0.6 1157088 6916 ?        Ssl  19:16   0:00 /usr/sbin/lvmetad -f
root        934  0.0  0.2  46284  2612 ?        Ss   19:16   0:00 /usr/lib/systemd/systemd-udevd
root       1239  0.0  2.2 196024 22112 ?        SLsl 19:16   0:00 /usr/sbin/dmeventd -f
root       1291  0.0  0.0  55532   852 ?        S<sl 19:16   0:00 /sbin/auditd
root       1293  0.0  0.0  84556   912 ?        S<sl 19:16   0:00  \_ /sbin/audispd
root       1295  0.0  0.1  55620  1408 ?        S<   19:16   0:00      \_ /usr/sbin/sedispatch
rpc        1322  0.0  0.1  69256  1008 ?        Ss   19:16   0:00 /sbin/rpcbind -w
root       1323  0.0  0.5 228248  5716 ?        Ss   19:16   0:00 /usr/sbin/abrtd -d -s
root       1324  0.0  0.4 225916  4900 ?        Ss   19:16   0:00 /usr/bin/abrt-watch-log -F BUG: WARNING: at WARNING: CPU: INFO: possible recursive lo
root       1325  0.0  0.5 430628  5500 ?        Ssl  19:16   0:00 /usr/sbin/ModemManager
root       1327  0.0  0.2  52880  2816 ?        Ss   19:16   0:00 /usr/sbin/smartd -n -q never
root       1328  0.0  0.5 168304  5172 ?        Ss   19:16   0:00 /usr/bin/VGAuthService -s
root       1329  0.1  0.5 295564  5312 ?        Ssl  19:16   0:10 /usr/bin/vmtoolsd
root       1330  0.0  0.1  16900  1372 ?        SNs  19:16   0:00 /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/
root       1335  0.0  0.4 225916  4904 ?        Ss   19:16   0:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/Xorg.0.log -- /usr/bin/abrt-dump-xorg -
root       1338  0.0  0.1  21684  1304 ?        Ss   19:16   0:00 /usr/sbin/irqbalance --foreground
polkitd    1339  0.0  1.5 617096 15596 ?        Ssl  19:16   0:05 /usr/lib/polkit-1/polkitd --no-debug
root       1340  0.0  0.3  90568  3204 ?        Ss   19:16   0:00 /sbin/rngd -f
avahi      1342  0.0  0.2  62268  2272 ?        Ss   19:16   0:00 avahi-daemon: running [web.local]
avahi      1369  0.0  0.0  62140   396 ?        S    19:16   0:00  \_ avahi-daemon: chroot helper
rtkit      1346  0.0  0.1 198784  1796 ?        SNsl 19:16   0:00 /usr/libexec/rtkit-daemon
libstor+   1347  0.0  0.0   8580   824 ?        Ss   19:16   0:00 /usr/bin/lsmd -d
root       1351  0.0  0.7 452328  7520 ?        Ssl  19:16   0:00 /usr/libexec/udisks2/udisksd
root       1354  0.0  0.4 396708  4332 ?        Ssl  19:16   0:00 /usr/libexec/accounts-daemon
dbus       1355  0.0  0.3  61424  3352 ?        Ss   19:16   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activ
root       1360  0.0  0.1 201428  1272 ?        Ssl  19:16   0:00 /usr/sbin/gssproxy -D
chrony     1370  0.0  0.1 117808  1828 ?        S    19:16   0:00 /usr/sbin/chronyd
root       1401  0.0  0.1  26460  1820 ?        Ss   19:16   0:00 /usr/lib/systemd/systemd-logind
root       1421  0.0  0.0 115408   948 ?        S    19:16   0:00 /bin/bash /usr/sbin/ksmtuned
root      59426  0.0  0.0 108052   356 ?        S    21:45   0:00  \_ sleep 60
root       1717  0.0  0.4 112900  4316 ?        Ss   19:16   0:00 /usr/sbin/sshd -D
root       2439  0.0  0.6 163592  6352 ?        Ss   19:18   0:07  \_ sshd: root@pts/0
root       2481  0.0  0.3 116984  3436 pts/0    Ss   19:19   0:00  |   \_ -bash
root      59717  0.0  0.2 155748  2204 pts/0    R+   21:46   0:00  |   |   \_ ps auxf
root       2523  0.1  0.1 113416  1656 ?        Ss   19:19   0:08  |   \_ bash -c while [ -d /proc/$PPID ]; do sleep 1;head -v -n 8 /proc/meminfo; head
root      59716  0.0  0.0 108052   356 ?        S    21:46   0:00  |       \_ sleep 1
root       2463  0.0  0.6 163596  6032 ?        Ss   19:19   0:00  \_ sshd: root@notty
root       2473  0.0  0.2  74336  2964 ?        Ss   19:19   0:00      \_ /usr/libexec/openssh/sftp-server
root       1718  0.0  0.4 198072  4024 ?        Ss   19:16   0:00 /usr/sbin/cupsd -f
root       1721  0.0  0.4 220656  4808 ?        Ssl  19:16   0:00 /usr/sbin/rsyslogd -n
root       1722  0.0  1.7 574284 17508 ?        Ssl  19:16   0:00 /usr/bin/python2 -Es /usr/sbin/tuned -l -P
root       1731  0.0  0.1  27168  1072 ?        Ss   19:16   0:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
root       1732  0.0  1.5 1005128 15124 ?       Ssl  19:16   0:04 /usr/sbin/libvirtd
root       1735  0.0  0.0  53288   572 ?        Ss   19:16   0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root       1739  0.0  0.0  25908   948 ?        Ss   19:16   0:00 /usr/sbin/atd -f
root       1740  0.0  0.1 126384  1620 ?        Ss   19:16   0:00 /usr/sbin/crond -n
root       1785  0.0  0.4 481568  4716 ?        Ssl  19:16   0:00 /usr/sbin/gdm
root       2101  0.0  2.4 296108 24356 tty1     Ssl+ 19:16   0:00  \_ /usr/bin/X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for
root       2114  0.0  0.4 363244  4828 ?        Sl   19:16   0:00  \_ gdm-session-worker [pam/gdm-launch-environment]
gdm        2118  0.0  1.1 745104 11148 ?        Ssl  19:16   0:00      \_ /usr/libexec/gnome-session-binary --autostart /usr/share/gdm/greeter/autostar
gdm        2161  0.0 13.8 3242760 138120 ?      Sl   19:16   0:03          \_ /usr/bin/gnome-shell
gdm        2205  0.0  0.5 453320  5504 ?        Sl   19:16   0:00          |   \_ ibus-daemon --xim --panel disable
gdm        2208  0.0  0.3 376172  3564 ?        Sl   19:16   0:00          |       \_ /usr/libexec/ibus-dconf
gdm        2349  0.0  0.3 302356  3392 ?        Sl   19:16   0:00          |       \_ /usr/libexec/ibus-engine-simple
gdm        2248  0.0  1.5 615532 15052 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-xsettings
gdm        2249  0.0  0.3 376728  3420 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-a11y-settings
gdm        2251  0.0  1.3 464768 13544 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-clipboard
gdm        2254  0.0  1.6 779924 16800 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-color
gdm        2259  0.0  0.8 465660  7996 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-datetime
gdm        2260  0.0  0.3 380888  3012 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-housekeeping
gdm        2263  0.0  1.3 614508 13792 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-keyboard
gdm        2266  0.0  1.7 1012404 17800 ?       Sl   19:16   0:00          \_ /usr/libexec/gsd-media-keys
gdm        2275  0.0  0.2 300624  2880 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-mouse
gdm        2276  0.0  1.6 705792 16844 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-power
gdm        2279  0.0  0.4 363352  4556 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-print-notifications
gdm        2283  0.0  0.3 317852  3120 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-rfkill
gdm        2289  0.0  0.3 374360  3056 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-screensaver-proxy
gdm        2294  0.0  0.4 411736  4340 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-sharing
gdm        2299  0.0  0.5 472464  5180 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-smartcard
gdm        2306  0.0  0.4 455228  4916 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-sound
gdm        2309  0.0  1.6 623316 16424 ?        Sl   19:16   0:00          \_ /usr/libexec/gsd-wacom
root       1954  0.0  0.2  91792  2240 ?        Ss   19:16   0:00 /usr/libexec/postfix/master -w
postfix    1956  0.0  0.4  92036  4308 ?        S    19:16   0:00  \_ qmgr -l -t unix -u
postfix   49072  0.0  0.4  89920  4636 ?        S    21:19   0:00  \_ local -t unix
postfix   59558  0.0  0.4  91936  4088 ?        S    21:46   0:00  \_ bounce -z -t unix -u
nobody     2020  0.0  0.1  53876  1084 ?        S    19:16   0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --
root       2021  0.0  0.0  53848   380 ?        S    19:16   0:00  \_ /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-r
gdm        2123  0.0  0.0  59016   956 ?        S    19:16   0:00 dbus-launch --exit-with-session /usr/libexec/gnome-session-binary --autostart /usr/sh
gdm        2124  0.0  0.1  60400  1852 ?        Ss   19:16   0:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
gdm        2129  0.0  0.3 346800  3732 ?        Sl   19:16   0:00 /usr/libexec/at-spi-bus-launcher
gdm        2134  0.0  0.2  60064  2304 ?        S    19:16   0:00  \_ /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf
gdm        2136  0.0  0.3 233104  3948 ?        Sl   19:16   0:00 /usr/libexec/at-spi2-registryd --use-gnome-session
root       2169  0.0  0.5 430480  5252 ?        Ssl  19:16   0:00 /usr/libexec/upowerd
gdm        2186  0.0  0.6 1252312 6412 ?        S<l  19:16   0:00 /usr/bin/pulseaudio --start --log-target=syslog
gdm        2211  0.0  1.3 465092 13768 ?        Sl   19:16   0:00 /usr/libexec/ibus-x11 --kill-daemon
gdm        2216  0.0  0.5 376152  5496 ?        Sl   19:16   0:00 /usr/libexec/ibus-portal
gdm        2224  0.0  0.2 364920  2896 ?        Sl   19:16   0:00 /usr/libexec/xdg-permission-store
root       2232  0.0  0.4 398900  4136 ?        Ssl  19:16   0:00 /usr/libexec/boltd
root       2236  0.0  0.3  78660  3356 ?        Ss   19:16   0:00 /usr/sbin/wpa_supplicant -u -f /var/log/wpa_supplicant.log -c /etc/wpa_supplicant/wpa
root       2242  0.0  0.5 410836  5588 ?        Ssl  19:16   0:00 /usr/libexec/packagekitd
colord     2326  0.0  0.6 419688  6372 ?        Ssl  19:16   0:00 /usr/libexec/colord
[root@web ~]# ps pidof
error: process ID list syntax errorUsage:ps [options]Try 'ps --help <simple|list|output|threads|misc|all>'or 'ps --help <s|l|o|t|m|a>'for additional help text.For more details see ps(1).
您在 /var/spool/mail/root 中有邮件
[root@web ~]# pidof
[root@web ~]# pidof bash
2523 2481 1421
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim process.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat process.sh
#!/bin/bash
# Name:process.sh
# Path:/root
# Usage:/root
# Describe:判断进程是否存在
read -p "请输入需要判断的进程名:" process
pgrep $process &> /dev/null
if [ $? -eq 0];thenecho "进程$process存在"
elseecho "进程$process不存在"
fi[root@web ~]# chmod +x process.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./process
-bash: ./process: 没有那个文件或目录
[root@web ~]# ./process.sh
请输入需要判断的进程名:rsyncd
./process.sh: 第 8 行:[: 缺少 `]'
进程rsyncd不存在
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim process.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat process.sh
#!/bin/bash
# Name:process.sh
# Path:/root
# Usage:/root
# Describe:判断进程是否存在
read -p "请输入需要判断的进程名:" process
pgrep $process &> /dev/null
if [ $? -eq 0 ];thenecho "进程$process存在"
elseecho "进程$process不存在"
fi[root@web ~]# ./process.sh
请输入需要判断的进程名:ps
进程ps存在
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim process1.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# cat process1.sh
#!/bin/bash
# Name:process2.sh
# Path:/root
# Usage:/root/process2.sh
# Describe:chage the processread -p "process name::" process
pgrep $process &>/dev/null
[ $? -eq 0 ] && echo "进程$process 存在" || echo "进程$process 不存在"
[root@web ~]# chmod +x process1.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./process1.sh
process name::ps
进程ps 存在
[root@web ~]# pgrep -o
1
[root@web ~]# pgrep -n
91660
[root@web ~]# pgrep -l
pgrep: no matching criteria specified
Try `pgrep --help' for more information.
您在 /var/spool/mail/root 中有邮件
[root@web ~]# pgrep -p 91660
pgrep:无效选项 -- pUsage: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-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 samenamespace as <pid>--nslist <ns,...>         list which namespaces will be considered forthe --ns option.Available namespaces: ipc, mnt, net, pid, user, uts-h, --help     display this help and exit-V, --version  output version information and exitFor more details see pgrep(1).
[root@web ~]# pgrep -P 91660
[root@web ~]# pgrep -g
pgrep:选项需要一个参数 -- gUsage: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-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 samenamespace as <pid>--nslist <ns,...>         list which namespaces will be considered forthe --ns option.Available namespaces: ipc, mnt, net, pid, user, uts-h, --help     display this help and exit-V, --version  output version information and exitFor more details see pgrep(1).
[root@web ~]# pgrep -t
pgrep:选项需要一个参数 -- tUsage: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-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 samenamespace as <pid>--nslist <ns,...>         list which namespaces will be considered forthe --ns option.Available namespaces: ipc, mnt, net, pid, user, uts-h, --help     display this help and exit-V, --version  output version information and exitFor more details see pgrep(1).
[root@web ~]# pgrep -u
pgrep:选项需要一个参数 -- uUsage: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-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 samenamespace as <pid>--nslist <ns,...>         list which namespaces will be considered forthe --ns option.Available namespaces: ipc, mnt, net, pid, user, uts-h, --help     display this help and exit-V, --version  output version information and exitFor more details see pgrep(1).
[root@web ~]# wget http://10.1.1.2
--2025-08-04 23:10:39--  http://10.1.1.2/
正在连接 10.1.1.2:80... ^C
您在 /var/spool/mail/root 中有邮件
[root@web ~]# vim serverOk.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# chmod +x serverOK.sh
chmod: 无法访问"serverOK.sh": 没有那个文件或目录
[root@web ~]# cat serverOK.sh
cat: serverOK.sh: 没有那个文件或目录
[root@web ~]# cat serverOk.sh
#!/bin/bash
wget http://10.1.1.2 &>/dev/null
[ $? -eq 0 ] && echo "该web服务正常" && rm -f /root/index.* || echo "该web服务异常"
[root@web ~]# chmod +x serverOk.sh
您在 /var/spool/mail/root 中有邮件
[root@web ~]# ./serverOk.sh
该web服务异常
[root@web ~]#
http://www.xdnf.cn/news/1241803.html

相关文章:

  • 贯穿全生命周期,生成式AI正在重塑游戏行业
  • Coze Loop:开源智能体自动化流程编排平台原理与实践
  • k8s集群
  • 案件线索展示与交付项目
  • 数据结构:如何判断一个链表中是否存在环(Check for LOOP in Linked List)
  • 深度学习图像处理篇之AlexNet模型详解
  • 【PHP】对比两张图片的相似度
  • WPF 按钮背景色渐变
  • 服务器的Mysql 集群技术
  • linux下docker安装ollama
  • Petalinux快捷下载
  • 部署 Kibana 8.2.2 可视化管理 Elasticsearch 8.2.2 集群
  • RabbitMQ--介绍
  • 【深度学习新浪潮】近三年零样本图像分类研发进展调研
  • 文件与目录操作命令
  • MySQL 基本操作入门指南
  • Apache IoTDB(3):时序数据库 IoTDB Docker部署实战
  • [GYCTF2020]FlaskApp
  • Nginx vs Spring Cloud Gateway:限流功能深度对比与实践指南
  • 直角坐标系里的四象限对NLP中的深层语义分析的积极影响和启示
  • spring boot开发中的资源处理等问题
  • 怎样推动AI技术在人机协同中的发展?
  • RTSP/RTMP播放器超低延迟实战:无人机远控视觉链路的工程实践
  • vue3+vue-flow制作简单可拖拽可增删改流程图
  • Qt 自动无法加载数据库为空
  • Go语言select
  • 开源的现代数据探索和可视化平台:Apache Superset 使用 Docker Compose
  • 笔记本电脑联想T14重启后无法识别外置红米屏幕
  • 如何手动打包 Linux(麒麟系统)的 Qt 程序
  • JVM学习专题(四)对象创建过程