Linux根据端口号查看进程PID

1、命令lsof,以查找占用端口80为例,用法如下:

[root@localhost nginx]# lsof -i:80
[root@localhost nginx]# 

  以上为没有进程占用80端口,

[root@localhost sbin]# lsof -i:80
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   8246   root    6u  IPv4  64233      0t0  TCP *:http (LISTEN)
nginx   8247 nobody    6u  IPv4  64233      0t0  TCP *:http (LISTEN)
[root@localhost sbin]# 

  以上为进程ID为8246和8247的nginx应用,占用80端口。

 

2、命令netstat,以查找占用80端口为例,用法如下:

[root@localhost sbin]# netstat -nlp|grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      8246/nginx          
[root@localhost sbin]# 

 

3、命令ps,可以查看已知进程PID的执行目录的详细信息

[root@localhost sbin]# ps -ef | grep 8246
root       8246      1  0 14:56 ?        00:00:00 nginx: master process ./nginx
nobody     8247   8246  0 14:56 ?        00:00:00 nginx: worker process
root       8461   2679  0 15:26 pts/1    00:00:00 grep 8246
[root@localhost sbin]# ps -x | grep 8246  
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
  8246 ?        Ss     0:00 nginx: master process ./nginx
  8463 pts/1    S+     0:00 grep 8246
[root@localhost sbin]# 

 

转载于:https://www.cnblogs.com/alsodzy/p/8522710.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值