记录 linux 排查端口占用 的常用命令
找到端口占用PIDkill -9 xxx
就可以了
netstat -tlnp
- -t: 显示TCP端口
- -l: 显示监听状态的端口
- -n: 显示端口号
- -p: 显示进程ID和进程名称
lsof -i | grep xxxx
xxxx是具体的端口
lsof -i | grep 8080
lsof 是列出打开文件的工具 用习惯了 这种方式也可以查到端口占用的PID
- -i: 显示网络文件
其他常用命令 ss|fuser|sockstat
ss -tlnp
: 显示TCP监听端口和进程信息fuser 9000/tcp
: 显示占用9000端口的进程号sockstat -l
: 显示监听端口和进程信息