【发布时间】:2012-11-05 08:55:00
【问题描述】:
在 Windows 和 Linux 上,如何找出哪个进程正在侦听哪个端口? 是否有一些应用程序明确监控?
【问题讨论】:
标签: linux windows networking
在 Windows 和 Linux 上,如何找出哪个进程正在侦听哪个端口? 是否有一些应用程序明确监控?
【问题讨论】:
标签: linux windows networking
一些很棒的工具是由 Sysinternals 开发的,现在归微软所有。
你想要的是 Tcpview,它会显示端口和打开了端口的应用程序,以及 PID 和其他好东西。 Tcpview 是基于 Windows 的,但它们也有命令行版本。所有这些工具都是免费的。
【讨论】:
Windows 和 Linux 都内置了 netstat-command,尽管它们的使用方式不同。
在 Windows 上:netstat -a -b(列出监听和连接的端口)
在 Linux 上:netstat -l -p(仅列出监听端口)
【讨论】:
在 Windows 7 上,您可以使用
netstat -b -a
netstat /?
-b Displays the executable involved in creating each connection or
listening port. In some cases well-known executables host
multiple independent components, and in these cases the
sequence of components involved in creating the connection
or listening port is displayed. In this case the executable
name is in [] at the bottom, on top is the component it called,
and so forth until TCP/IP was reached. Note that this option
can be time-consuming and will fail unless you have sufficient
permissions.
-o Displays the owning process ID associated with each connection.
在 Linux 上使用,-p 需要 root 权限。
#netstat -p
#netstat -h
-p, --programs display PID/Program name for sockets
【讨论】:
不确定 stackoverflow 是否适合这个问题,也许http://www.superuser.com 会是更好的选择。
虽然从我的头顶:
lsof 和netstat 命令可以提供这些信息。ProcessExplorer 应该提供此信息。【讨论】:
在 Linux 中,您可以使用ss 命令转储套接字信息。它还提供有关客户端活动端口号的信息。更多详情可在这找到
http://linux.die.net/man/8/ss
【讨论】: