Linux根据进程名查看进程id,以及根据进程id查看占用的端口,根据端口号查看占用的进程[通俗易懂]

Linux根据进程名查看进程id,以及根据进程id查看占用的端口,根据端口号查看占用的进程[通俗易懂]1.先根据进程名查看进程idpsaux|grep进程名(或者ps-ef|grep进程名)y@ubuntu:~$psaux|grepbitcoindy270810112.11611172488580?SslAug2232:04bitcoind-daemon-connect=172.16.247.139y…

大家好,欢迎来到IT知识分享网。

  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

IT知识分享网

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

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

方式(1): ps -aux | grep 进程id

方式(2):netstat -nap | grep 进程id

IT知识分享网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

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/4187.html

(0)
上一篇 2022-11-24 15:29
下一篇 2022-11-24 16:16

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信