通过端口号查看占用的进程ID
netstat -nap | grep 端口号
[root@t-enter ~]# 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
通过进程ID查看占用的端口
netstat -nap | grep 进程id
[root@t-enter ~]# 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
根据进程名查看进程ID
ps aux | grep 进程名(或者ps -ef | grep 进程名)
[root@t-enter ~]# ps aux | grep bitcoind
2708 101 12.1 1611172 488580 ? Ssl Aug22 32:04 bitcoind -daemon -connect=172.16.247.139
3564 0.0 0.0 21536 1092 pts/0 S+ 00:23 0:00 grep --color=auto bitcoind
可以看到,bitcoind进程的pid是2708