1、根据端口号查进程pid
lsof -i:port
netstat -nap|grep port
2、根据进程号查端口
netstat -nap|grep pid
3、根据进程pid查看服务路径
ps -ef|grep java 查看进程pid
ll /proc/pid/cwd 查看服务安装路径
netstat -nap|grep 8080
root@debian:/home/zxl# netstat -nap|grep 8080
tcp6 0 0 :::8080 :::* LISTEN 16331/./beego
tcp6 0 0 ::1:8080 ::1:52370 ESTABLISHED 16331/./beego
tcp6 0 0 ::1:52370 ::1:8080 ESTABLISHED 11955/chrome --type
root@debian:/home/zxl# kill -9 16331
root@debian:/home/zxl# netstat -nap|grep 8080
tcp6 0 0 ::1:8080 ::1:52370 FIN_WAIT2 -
tcp6 1 0 ::1:52370 ::1:8080 CLOSE_WAIT 11955/chrome --type
root@debian:/home/zxl#