搜索
查看: 1185|: 0

在GNU/Linux中查看端口占用情况的命令

[复制链接]

205

主题

5

回帖

755

积分

高级会员

积分
755
发表于 2014-9-16 16:10:29 | 显示全部楼层 |阅读模式

/*********************************************************************
* Author : Samson
* Date : 04/08/2014
* Test platform:
* Linux debian-IDS 3.13.7
* GNU bash, version 4.2.37
* *******************************************************************/

第一种方法:

root@debian:/home/# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:33223 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
tcp6 0 0 :::60042 :::* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 111.111.111.120:80 111.111.111.114:1119 ESTABLISHED
tcp6 0 0 111.111.111.120:80 111.111.111.114:1123 ESTABLISHED
tcp6 0 0 111.111.111.120:80 111.111.111.114:1125 TIME_WAIT
tcp6 0 0 111.111.111.120:80 111.111.111.114:1112 TIME_WAIT
tcp6 0 0 111.111.111.120:80 111.111.111.114:1110 TIME_WAIT
tcp6 0 0 111.111.111.120:80 111.111.111.114:1122 ESTABLISHED
tcp6 0 0 111.111.111.120:80 111.111.111.114:1114 TIME_WAIT
tcp6 0 0 111.111.111.120:80 111.111.111.114:1117 TIME_WAIT

第二种方法:

root@debian:/home# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 2301 root 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 2497 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 2498 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 2499 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 2500 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 2501 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 6108 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 6117 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)
apache2 6118 www-data 4u IPv6 7298 0t0 TCP *:http (LISTEN)

//mysql default port

root@debian:/home# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 2992 mysql 10u IPv4 9546 0t0 TCP localhost:mysql (LISTEN)


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

大数据中国微信

QQ   

版权所有: Discuz! © 2001-2013 大数据.

GMT+8, 2024-12-23 23:13 , Processed in 0.172837 second(s), 24 queries .

快速回复 返回顶部 返回列表