Linux 关闭指定端口号的所有进程

kill -9 $(lsof -i tcp:端口 -t);

例如(8080):

kill -9 $(lsof -i tcp:8080 -t);

若没有安装 lsof,则需要使用 netstat

netstat -nlp | grep :8080 | awk '{print $7}' | awk -F"/" '{ print $1 }'

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
32367

kill 32367

1 条评论

  1. reviewer
    Biqiasao
    2022年11月28日

    Show all information.

    ```
    netstat -nlp | grep :3000 | awk '{print $7}'
    ```

    回复

Biqiasao进行回复 取消回复

您的电子邮箱地址不会被公开。