Linux查看進程id,以及根據進程id查看占用的端口,根據端口號查看占用的進程


 

應該是轉載了別人的。

 

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM