Linux查看进程id,以及根据进程id查看占用的端口,根据端口号查看占用的进程

转载自:https://blog.csdn.net/yzpbright/article/details/81981755

1. 先根据进程名查看进程id

ps aux | grep 进程名(或者ps -ef | grep 进程名)

y@ubuntu:~$ ps aux | grep bitcoind
y          2708  101 12.1 1611172 488580 ?      Ssl  Aug22  32:04 bitcoind -daemon -connect=172.16.247.139
y          3564  0.0  0.0  21536  1092 pts/0    S+   00:23   0:00 grep --color=auto bitcoind

可以看到,bitcoind进程的pid是2708

2.通过进程id查看占用的端口

netstat -nap | grep 进程id

y@ubuntu:~$ netstat -nap | grep 2708
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:8332          0.0.0.0:*               LISTEN      2708/bitcoind       
tcp6       0      0 ::1:8332                :::*                    LISTEN      2708/bitcoind 

可以看到,pid=2708的进程占用的端口号是8332

3.通过端口号查看占用的进程id

netstat -nap | grep 端口号

y@ubuntu:~$ netstat -nap | grep 8332
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:8332          0.0.0.0:*               LISTEN      2708/bitcoind       
tcp6       0      0 ::1:8332                :::*                    LISTEN      2708/bitcoind  

可以看到,占用8332端口的是进程的pid是2708,名称是bitcoind

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值