根据端口查进程
lsof -i:port
netstat -nap | grep port
根据进程号查端口
lsof -i | grep pid
netstat -nap | grep pid
根据进程名查找pid、port
ps -ef | grep tomcat
ps -ef | grep pid
netstat无法显示PID或进程名
$ netstat -nap | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::8080 :::* LISTEN -
执行netstat -anop后得到如上结果,有些端口占用没有进程的pid和Program Name,使用root执行即可