需要安装lsof工具

比如查8999端口:

lsof -i:8999|awk '{if(NR>1) print $2}'

如果返回空表示没被占用