1. 根据进程pid查端口:
lsof -i | grep pid
netstat -nap | grep pid
2. 根据端口port查进程:
lsof -i:port
netstat -nap | grep port