以 80 端口为例。
首先,列出任何监听端口 80 的进程:
# 使用 lsof
$ lsof -i:80
# 使用 fuser
$ fuser 80/tcp
使用 kill
命令删除任何监听端口 80 的进程:
$ kill $(lsof -t -i:80)
$ kill -9 $(lsof -t -i:80)
或使用 fuser
命令:
$ fuser -k 80/tcp
更多资源
- Finding the PID of the process using a specific port?
- How to kill a process running on particular port in Linux?