1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| [root@yum_repo ~]# ps aux|sort -k 4 -nr [root@yum_repo ~]# ps aux --sort %mem (默认占比最小的显示最前)
[root@yum_repo ~]# ps axo user,pid,ppid,%mem,command,%cpu
1.先查还有没有这个服务 [root@localhost ~]# ps aux|grep nginx root 10021 0.0 0.0 39304 940 ? Ss 16:44 0:00 nginx: master process /usr/sbin/nginx nginx 10022 0.0 0.1 39692 1896 ? S 16:44 0:00 nginx: worker process 2.使用端口号命令来查看该端口是否被监听。如果端口处于监听状态,则说明服务已经启动(nginx默认80端口,http协议)
[root@lb01 ~]# netstat -lntup Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8752/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6625/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6708/master tcp6 0 0 :::80 :::* LISTEN 8752/nginx: master tcp6 0 0 :::22 :::* LISTEN 6625/sshd tcp6 0 0 ::1:25 :::* LISTEN 6708/master [root@lb01 ~]# netstat -tulun Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
[root@yum_repo ~]# ps aux |grep nginx|grep -v grep [root@yum_repo ~]# ps aux|grep nginx root 19740 0.0 0.1 39312 1044 ? Ss 12:00 0:00 nginx: master process /usr/sbin/nginx nginx 19741 0.0 0.1 39700 1816 ? S 12:00 0:00 nginx: worker process nginx 19742 0.0 0.1 39700 1816 ? S 12:00 0:00 nginx: worker process nginx 19759 0.0 0.1 39700 1816 ? S 12:00 0:00 nginx: worker process nginx 19760 0.0 0.1 39700 1556 ? S 12:00 0:00 nginx: worker process root 19823 0.0 0.0 112812 980 pts/2 R+ 12:05 0:00 grep -- color=auto nginx
[root@yum_repo ~]# ps aux|grep [n]ginx grep nginx root 19823 0.0 0.0 112812 980 pts/2 R+ 12:05 0:00 grep -- color=auto [n]ginx
[root@zls ~]# pgrep sshd 869 1194 1307 1574 [root@zls ~]# pgrep -l sshd 显示进程名及ID 869 sshd 1194 sshd 1307 sshd 1574 sshd [root@zls ~]# pgrep -l -a sshd 869 /usr/sbin/sshd -D 1194 sshd: root@pts/0 1307 sshd: root@pts/1 1574 sshd: root@pts/2
[root@zls ~]# pidof sshd 1574 1307 1194 869
[root@yum_repo ~]# pstree systemd─┬─NetworkManager───2*[{NetworkManager}] ├─VGAuthService ├─agetty ├─auditd───{auditd} ├─crond───crond───sh───ntpdate ├─dbus-daemon ├─gssproxy───5*[{gssproxy}] ├─nginx───20*[nginx] ├─polkitd───6*[{polkitd}]
|