判断监听某个端口的程序
上一篇 /
下一篇 2007-11-28 12:56:31
/ 个人分类:Linux
使用netstat -anp 查看正在监听该端口的程序的PID,然后使用ps命令根据该PID得到对应的程序
如:
[root@Admin root]# netstat -anp51Testing软件测试网\9@4H)_zb6`
Active Internet connections (servers and established)
'M.s'p`$d5o0Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
yj d2A2We*ml0tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN 2124/ 51Testing软件测试网VM*v!Kw3Z_
pd~Q
tcp 0 0 127.0.0.1:32769 0.0.0.0:* LISTEN 2248/xinetd
)D.z$t5_,tL7xr5\
lr0tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 2226/java
\Yd*S.}0tcp 0 0 127.0.0.1:8009 0.0.0.0:* LISTEN 2226/java 51Testing软件测试网THdQ
Ax
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2105/ 51Testing软件测试网s+J1S \2p!eB&Ye&J_1R
tcp 0 0 192.168.0.16:80 0.0.0.0:* LISTEN 2226/java
得到监听80端口的程序的PID为2226
然后执行ps -ef |grep 2226
[root@Admin root]# ps -ef |grep 222651Testing软件测试网9z+Ni B8@a
root 2226 1 0 Apr11 ? 00:01:29 /home/admin/j2sdk1.4.0_01//bin/java -Djava.endorsed.dirs=/home/admin/jakarta-tomcat-4.1.18/bin:/home/admin/jakarta-tomcat-4.1.18/common/endorsed -classpath /home/admin/j2sdk1.4.0_01//lib/tools.jar:/home/admin/jakarta-tomcat-4.1.18/bin/bootstrap.jar -Dcatalina.base=/home/a
HTWY~
v4V&`'N0root 3615 3578 0 13:45 pts/1 00:00:00 grep 2226
从而确定该程序为 :/home/admin/jakarta-tomcat-4.1.18
注:2007年4月12日写于msn共享空间
相关阅读:
- 性能测试之linux指令篇1 (thefirstred, 2007-11-28)
- 平生第一个shell脚本 (thefirstred, 2007-11-28)
- shell通配符 (thefirstred, 2007-11-28)
- 正则表达式 (thefirstred, 2007-11-28)
- bash 比较运算符 (thefirstred, 2007-11-28)
- 在linux下安装配置mysql+freeradius (thefirstred, 2007-11-28)
- linux启动过程 (thefirstred, 2007-11-28)
- 在linux下打印 (thefirstred, 2007-11-28)
- export、env、set三者的区别 (thefirstred, 2007-11-28)
- 查看当前shell (thefirstred, 2007-11-28)
收藏
举报
TAG:
Linux