[root@localhost huage]# netstat -anp |grep 111
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1415/rpcbind
tcp 0 0 :::111 :::* LISTEN 1415/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 1415/rpcbind
udp 0 0 :::111 :::* 1415/rpcbind
netstat:
-a 显示全部
-a, --all
Show both listening and non-listening sockets. With the --interfaces option, show
interfaces that are not marked
-n 显示端口号而不是名称
--numeric , -n
Show numerical addresses instead of trying to determine symbolic host, port or user
names.
-p 显示相关进程的PID及程序
-p, --program
Show the PID and name of the program to which each socket belongs.
-t 显示已经建立的连接
[root@1-min test]# netstat -npt
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 52 192.168.18.129:22 192.168.18.1:52826 ESTABLISHED 1628/sshd: huage [p
tcp 0 0 192.168.18.129:22 192.168.18.1:52422 ESTABLISHED 1575/sshd: huage [p
tcp 0 0 192.168.18.129:2049 192.168.18.136:697 ESTABLISHED -
tcp 0 0 192.168.18.129:22 192.168.18.1:51551 ESTABLISHED 1532/sshd: huage [p
根据端口号来查询PID之二:
[root@localhost huage]# lsof -i:111 //冒号后接的是端口号
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rpcbind 1415 rpc 6u IPv4 11465 0t0 UDP *:sunrpc
rpcbind 1415 rpc 8u IPv4 11470 0t0 TCP *:sunrpc (LISTEN)
rpcbind 1415 rpc 9u IPv6 11472 0t0 UDP *:sunrpc
rpcbind 1415 rpc 11u IPv6 11475 0t0 TCP *:sunrpc (LISTEN)
转载自:http://blog.sina.com.cn/s/blog_716844910100te6z.html
转载于:https://blog.51cto.com/babyhe/1135615