美文网首页
Linux(Debian、Ubuntu、RHEL、CentOS等

Linux(Debian、Ubuntu、RHEL、CentOS等

作者: 三猫夜行 | 来源:发表于2023-04-13 01:16 被阅读0次

安装必要软件

sudo apt-get update
sudo apt-get install net-tools lsof -y

查看端口占用情况(以Node.js默认的3000端口为例)

## 使用 netstat
netstat -lnp|grep 3000
# 输出结果中的 `29/node` 列即为进程ID/调用命令
#tcp6       0      0 :::3000                 :::*                    LISTEN      29/node

## 或者 lsof
lsof -i:3000
# 输出结果中的 `PID` 列即为进程ID
# COMMAND PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
# node     29 root   18u  IPv6 642925968      0t0  TCP *:3000 (LISTEN)

强制关闭端口

kill -9 进程ID

原文网址如下,转载敬请标明出处,谢谢。
https://kamaslau.wordpress.com/2022/03/08/linux-ubuntu-debian-rhel-centos-port-occupation-check-and-force-quit/

相关文章

网友评论

      本文标题:Linux(Debian、Ubuntu、RHEL、CentOS等

      本文链接:https://www.haomeiwen.com/subject/bccaddtx.html