侦听端口 linux_如何找到哪个程序或进程正在Linux的某个端口上侦听?

侦听端口 linux

My program reports that the port is already used.

我的程序报告该端口已被使用。

How to find which program or process is listening on a certain port in Linux?

如何找到Linux上某个端口上正在侦听的程序或进程?

You can use netstat to do this. netstat can print network connections.

您可以使用netstat来执行此操作。 netstat可以打印网络连接。

For example, to find which program is listing on port 9999

例如,查找哪个程序在端口9999上列出

netstat -pln | grep 9999

You will need to use sudo to get more details, such as process names that are now owned by you.

您将需要使用sudo来获取更多详细信息,例如您现在拥有的进程名称。

sudo netstat -pln | grep 9999

Here, p makes netstat print process name, ‘l’ means “listening” and ‘n’ means numerical addresses instead of trying to determine symbolic host, port or user names.

在这里, p netstat打印进程名称,“ l”代表“监听”,“ n”代表数字地址,而不是试图确定符号主机名,端口名或用户名。

If you are sure that the programming is using TCP or UDP, you can also add option t or u to filter out only TCP and UDP connections like

如果确定编程使用的是TCP或UDP,还可以添加选项tu仅过滤出TCP和UDP连接,例如

sudo netstat -ptln | grep 9999
sudo netstat -puln | grep 9999

For more details, please check netstat manual.

有关更多详细信息,请查阅netstat手册

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/how-to-find-which-program-or-process-is-listening-on-a-certain-port-in-linux/

侦听端口 linux

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值