[mark]常用Linux命令

209 阅读2分钟

1,根据端口号查看进程PID Isof


> lsof -i:80
COMMAND     PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
AliYunDun  1441 root   28u  IPv4 284034050      0t0  TCP izbp1ierao41xx0raqqt6mz:52358->100.100.30.26:http (ESTABLISHED)
nginx      8885 root    6u  IPv4 152256714      0t0  TCP *:http (LISTEN)
nginx     22736 root    6u  IPv4 152256714      0t0  TCP *:http (LISTEN)
nginx     22737 root    6u  IPv4 152256714      0t0  TCP *:http (LISTEN)
nginx     22737 root   13u  IPv4 294831122      0t0  TCP izbp1ierao41xx0raqqt6mz:http->114.93.31.70:36690 (ESTABLISHED)
nginx     22738 root    6u  IPv4 152256714      0t0  TCP *:http (LISTEN)

2,netstat去查看端口占用

> netstat -nlp | grep :80
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      8885/nginx: master
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      8885/nginx: master
tcp        0      0 0.0.0.0:8020            0.0.0.0:*               LISTEN      8885/nginx: master
tcp6       0      0 :::8030                 :::*                    LISTEN      32723/node

获取到 PID 8885

3,通过PID 获取到执行的详细信息

> ps -ef | grep 8885
root      8885     1  0  2019 ?        00:00:00 nginx: master process ./nginx -c /app/nginx/conf/nginx.conf
root     22736  8885  0  2019 ?        00:00:05 nginx: worker process
root     22737  8885  0  2019 ?        00:00:15 nginx: worker process
root     22738  8885  0  2019 ?        00:00:42 nginx: worker process
root     22739  8885  0  2019 ?        00:00:23 nginx: worker process
root     27499 21765  0 16:54 pts/0    00:00:00 grep --color=auto 8885
[root@izbp1ierao41xx0raqqt6mz app]#

看到执行住主进程和执行脚本 ./nginx -c /app/nginx/conf/nginx.conf r

深度拷贝