参考自:
https://access.redhat.com/solutions/1987
How do I list the open ports on my system and the process that owns them?
使用lsof -i命令即可:
[root@abc ~]# lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rpcbind 1644 rpc 6u IPv4 11565 0t0 UDP *:sunrpc
rpcbind 1644 rpc 7u IPv4 11567 0t0 UDP *:971
rpcbind 1644 rpc 8u IPv4 11568 0t0 TCP *:sunrpc (LISTEN)
rpcbind 1644 rpc 9u IPv6 11570 0t0 UDP *:sunrpc
rpcbind 1644 rpc 10u IPv6 11572 0t0 UDP *:971
rpcbind 1644 rpc 11u IPv6 11573 0t0 TCP *:sunrpc (LISTEN)
rpc.statd 1701 rpcuser 7u IPv4 11839 0t0 UDP *:48976
rpc.statd 1701 rpcuser 8u IPv4 11843 0t0 TCP *:63124 (LISTEN)
rpc.statd 1701 rpcuser 9u IPv6 11847 0t0 UDP *:48394
rpc.statd 1701 rpcuser 10u IPv6 11851 0t0 TCP *:57162 (LISTEN)
rpc.statd 1701 rpcuser 59u IPv4 11834 0t0 UDP localhost:659
cupsd 1746 root 6u IPv6 12130 0t0 TCP localhost:ipp (LISTEN)
cupsd 1746 root 7u IPv4 12131 0t0 TCP localhost:ipp (LISTEN)
cupsd 1746 root 9u IPv4 12134 0t0 UDP *:ipp
sshd 1937 root 3u IPv4 12699 0t0 TCP *:ssh (LISTEN)
sshd 1937 root 4u IPv6 12701 0t0 TCP *:ssh (LISTEN)
master 2016 root 12u IPv4 12911 0t0 TCP localhost:smtp (LISTEN)
master 2016 root 13u IPv6 12913 0t0 TCP localhost:smtp (LISTEN)
postgres 2072 highgo432 3u IPv4 13145 0t0 TCP *:postgres (LISTEN)
postgres 2072 highgo432 4u IPv6 13146 0t0 TCP *:postgres (LISTEN)
postgres 2072 highgo432 8u IPv6 13161 0t0 UDP localhost:59722->localhost:59722
postgres 2074 highgo432 8u IPv6 13161 0t0 UDP localhost:59722->localhost:59722
postgres 2075 highgo432 8u IPv6 13161 0t0 UDP localhost:59722->localhost:59722
postgres 2076 highgo432 8u IPv6 13161 0t0 UDP localhost:59722->localhost:59722
postgres 2077 highgo432 8u IPv6 13161 0t0 UDP localhost:59722->localhost:59722
postgres 2078 highgo432 8u IPv6 13161 0t0 UDP localhost:59722->localhost:59722
postgres 4877 highgo475 3u IPv4 18837 0t0 TCP *:5899 (LISTEN)
postgres 4877 highgo475 4u IPv6 18838 0t0 TCP *:5899 (LISTEN)
postgres 4877 highgo475 8u IPv6 18853 0t0 UDP localhost:60657->localhost:60657
postgres 4879 highgo475 8u IPv6 18853 0t0 UDP localhost:60657->localhost:60657
postgres 4880 highgo475 8u IPv6 18853 0t0 UDP localhost:60657->localhost:60657
postgres 4881 highgo475 8u IPv6 18853 0t0 UDP localhost:60657->localhost:60657
postgres 4882 highgo475 8u IPv6 18853 0t0 UDP localhost:60657->localhost:60657
postgres 4883 highgo475 8u IPv6 18853 0t0 UDP localhost:60657->localhost:60657
sshd 14619 root 3r IPv4 46824 0t0 TCP abc:ssh->192.168.80.1:64586 (ESTABLISHED)
[root@abc ~]#