1.根据端口号判断端口是否被占用
lsof -i:端口号
2.根据进程号获取占用端口
netstat -anp |grep 进程号
只显示监听端口:
netstat -lnp |grep 进程号
其他:
获取进程打开文件句柄。
lsof -p 进程号