查看占用端口的程序
查看进程占用
lsof -i tcp:8080
该命令会显示占用8080端口的进程,有其 pid ,可以通过pid关掉该进程
杀死进程
kill pid
java
# 查看
➜ Java sudo lsof -n -P | grep :****
或者lsof -i :****
➜ Java sudo lsof -n -P | grep :8080
ClashX 1662 izhaong 177u IPv4 0x5a2f7732da1d8707 0t0 TCP 192.168.63.2:62100->109.244.152.174:8080 (ESTABLISHED)
QQ 32270 izhaong 35u IPv4 0x5a2f7732d95c8c67 0t0 TCP 198.18.0.1:62099->109.244.152.174:8080 (ESTABLISHED)
QQ 32270 izhaong 36u IPv4 0x5a2f7732d95c8c67 0t0 TCP 198.18.0.1:62099->109.244.152.174:8080 (ESTABLISHED)
java 38362 izhaong 86u IPv6 0x5a2f774133dc0bcf 0t0 TCP *:8080 (LISTEN)
1
2
3
4
5
2
3
4
5
# 杀掉进程
kill *****
➜ Java kill 38362
1
➜ Java lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ClashX 1662 izhaong 177u IPv4 0x5a2f7732da1d8707 0t0 TCP 192.168.63.2:62100->109.244.152.174:http-alt (ESTABLISHED)
QQ 32270 izhaong 35u IPv4 0x5a2f7732d95c8c67 0t0 TCP 198.18.0.1:62099->109.244.152.174:http-alt (ESTABLISHED)
QQ 32270 izhaong 36u IPv4 0x5a2f7732d95c8c67 0t0 TCP 198.18.0.1:62099->109.244.152.174:http-alt (ESTABLISHED)
1
2
3
4
5
2
3
4
5
上次更新: 2023/06/10, 12:06:41