lsof -i:port | grep pid
例子:(根据端口号查看pid)
lsof -i:5432
[postgres@localhost ~]$ lsof -i:5432 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME postgres 4662 postgres 3u IPv4 48819 0t0 TCP *:postgres (LISTEN) postgres 4662 postgres 4u IPv6 48820 0t0 TCP *:postgres (LISTEN) postgres 9268 postgres 9u IPv4 98826 0t0 TCP localhost:postgres->localhost:globmsgsvc (ESTABLISHED) postgres 9269 postgres 9u IPv4 98828 0t0 TCP localhost:postgres->localhost:pvsw (ESTABLISHED)