Linux: 查找使用中的port

找出所有使用中的port

netstat -tulpn

输出

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1138/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 850/portmap
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1607/apache2
tcp 0 0 0.0.0.0:55091 0.0.0.0:* LISTEN 910/rpc.statd
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1467/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 992/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1565/cupsd

找出port对应的程序

ls -l /proc/1138/exe

输出

lrwxrwxrwx 1 root root 0 2010-10-29 10:20 /proc/1138/exe -> /usr/sbin/mysqld

找出特定的port

netstat -tulpn | grep :80

Mac

sudo lsof -i :80 # checks port 80

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 64888 wg 6u IPv4 0x6ddd270 0t0 TCP *:gds_db (LISTEN)

posted @ 2015-07-04 20:12  GreatK  阅读(648)  评论(0)    收藏  举报