一、使用netstat命令
#安装netstat
yum -y install net-tools
#检测端口占用
netstat -npl | grep 端口
# 几种常规用法
netstat -ntlp //查看当前所有tcp端口
netstat -ntulp | grep 8080 //查看所有8080端口使用情况
netstat -ntulp | grep 6379 //查看所有6379端口使用情况
二、使用lsof命令
#安装lsof
yum -y install lsof
#检测端口占用
lsof -i: 端口号