免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8021 | 回复: 8
打印 上一主题 下一主题

求教solaris如何查看当前某个端口是哪个进程在监听? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-26 11:20 |只看该作者 |倒序浏览
貌似用netstat看不到

论坛徽章:
0
2 [报告]
发表于 2008-08-26 11:31 |只看该作者
netstat -a | grep LISTEN

论坛徽章:
2
双鱼座
日期:2014-02-23 12:10:03操作系统版块每日发帖之星
日期:2015-12-17 06:20:00
3 [报告]
发表于 2008-08-26 11:34 |只看该作者
# netstat -a | grep LISTEN
      *.sunrpc             *.*                0      0 24576      0 LISTEN
      *.32771              *.*                0      0 24576      0 LISTEN
      *.ftp                *.*                0      0 24576      0 LISTEN
      *.telnet             *.*                0      0 24576      0 LISTEN
      *.shell              *.*                0      0 24576      0 LISTEN
      *.shell              *.*                0      0 24576      0 LISTEN
      *.login              *.*                0      0 24576      0 LISTEN
      *.exec               *.*                0      0 24576      0 LISTEN
      *.exec               *.*                0      0 24576      0 LISTEN
      *.uucp               *.*                0      0 24576      0 LISTEN
      *.finger             *.*                0      0 24576      0 LISTEN
      *.time               *.*                0      0 24576      0 LISTEN
      *.echo               *.*                0      0 24576      0 LISTEN
      *.discard            *.*                0      0 24576      0 LISTEN
      *.daytime            *.*                0      0 24576      0 LISTEN
      *.chargen            *.*                0      0 24576      0 LISTEN
      *.swat               *.*                0      0 24576      0 LISTEN
      *.32772              *.*                0      0 24576      0 LISTEN
      *.32773              *.*                0      0 24576      0 LISTEN
      *.32774              *.*                0      0 24576      0 LISTEN
      *.fs                 *.*                0      0 24576      0 LISTEN
      *.printer            *.*                0      0 24576      0 LISTEN
      *.dtspc              *.*                0      0 24576      0 LISTEN
      *.sun-dr             *.*                0      0 24576      0 LISTEN
      *.sun-dr             *.*                0      0 24576      0 LISTEN
      *.32775              *.*                0      0 24576      0 LISTEN
      *.lockd              *.*                0      0 24576      0 LISTEN
      *.5987               *.*                0      0 24576      0 LISTEN
      *.898                *.*                0      0 24576      0 LISTEN
      *.32784              *.*                0      0 24576      0 LISTEN
      *.9010               *.*                0      0 24576      0 LISTEN
      *.32803              *.*                0      0 24576      0 LISTEN
      *.2410               *.*                0      0 24576      0 LISTEN
      *.32810              *.*                0      0 24576      0 LISTEN
      *.445                *.*                0      0  8576      0 LISTEN
      *.netbios-ssn        *.*                0      0  8576      0 LISTEN
      *.32853              *.*                0      0 24576      0 LISTEN
      *.32854              *.*                0      0 24576      0 LISTEN
localhost.32871            *.*                0      0 24576      0 LISTEN
localhost.32874            *.*                0      0 24576      0 LISTEN
      *.smtp               *.*                0      0 24576      0 LISTEN
      *.smtp               *.*                0      0 24576      0 LISTEN
      *.submission         *.*                0      0 24576      0 LISTEN
      *.ftp                             *.*                             0      0 24576      0 LISTEN           
      *.telnet                          *.*                             0      0 24576      0 LISTEN           
      *.shell                           *.*                             0      0 24576      0 LISTEN           
      *.login                           *.*                             0      0 24576      0 LISTEN           
      *.exec                            *.*                             0      0 24576      0 LISTEN           
      *.finger                          *.*                             0      0 24576      0 LISTEN           
      *.time                            *.*                             0      0 24576      0 LISTEN           
      *.echo                            *.*                             0      0 24576      0 LISTEN           
      *.discard                         *.*                             0      0 24576      0 LISTEN           
      *.daytime                         *.*                             0      0 24576      0 LISTEN           
      *.chargen                         *.*                             0      0 24576      0 LISTEN           
      *.printer                         *.*                             0      0 24576      0 LISTEN           
      *.sun-dr                          *.*                             0      0 24576      0 LISTEN           
      *.smtp                            *.*                             0      0 24576      0 LISTEN

论坛徽章:
0
4 [报告]
发表于 2008-08-26 11:45 |只看该作者
谢谢楼上的几位!
我用openldap在5001端口监听
这样输出的是
localhost.5001           *.*                0      0 49152      0 LISTEN
还是没有进程的名字。。。

论坛徽章:
2
双鱼座
日期:2014-02-23 12:10:03操作系统版块每日发帖之星
日期:2015-12-17 06:20:00
5 [报告]
发表于 2008-08-26 11:54 |只看该作者
安装lsof吧,很好用的说,具体使用,请参见:http://blog.chinaunix.net/u/524/showart_296571.html

论坛徽章:
0
6 [报告]
发表于 2008-08-26 13:22 |只看该作者
lsof确实是个好东东啊

论坛徽章:
0
7 [报告]
发表于 2008-08-26 14:15 |只看该作者
找找前几天的帖子,有!

论坛徽章:
0
8 [报告]
发表于 2008-08-26 15:38 |只看该作者
below script will do the same thing as part of lsof, though I highly recommend lsof.

#!/bin/ksh
#
# 7-30-2003
# find from a port the pid that started the port
#
line='-------------------------------------------------------------------------'
pids=`/usr/bin/ps -ef | sed 1d | awk '{print $2}'`

# Prompt users or use 1st cmdline argument
if [ $# -eq 0 ]; then
         read ans?"Enter port you like to know pid for:  "
else
         ans=$1
fi

# Check all pids for this port, then list that process
for f in $pids
do
         /usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans"
         if [ $? -eq 0 ] ; then
                 echo "$line\nPort: $ans is being used by PID: \c"
                 /usr/bin/ps -o pid -o args -p $f | sed 1d
         fi
done
exit 0

[ 本帖最后由 shyjack 于 2008-8-26 15:39 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2008-08-26 19:15 |只看该作者
嗨 蜘蛛前阵子去哪里了。人影不见
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP