判断监听某个端口的程序
上一篇 /
下一篇 2007-11-28 12:56:31
/ 个人分类:Linux
使用netstat -anp 查看正在监听该端口的程序的PID,然后使用ps命令根据该PID得到对应的程序
如:
[root@Admin root]# netstat -anp51Testing软件测试网c a}u*c?^ M5f
Active Internet connections (servers and established)51Testing软件测试网(x{cAX_R
K
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 51Testing软件测试网r"a)B4dhtC
tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN 2124/
*[b$H;s9~;y-T"} A#^0tcp 0 0 127.0.0.1:32769 0.0.0.0:* LISTEN 2248/xinetd
\.EqE UL1H`0tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 2226/java 51Testing软件测试网n+Y#U%DSD|n
tcp 0 0 127.0.0.1:8009 0.0.0.0:* LISTEN 2226/java
1Sr `
m4`e[0tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2105/
"s!~I5^3aF6U0tcp 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软件测试网
f`AfX5I4Ox
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/a51Testing软件测试网2k,qmQ"w0a*a {R
root 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