问题描述
如何获取lsof
来生成数字端口信息,而不是尝试将端口解析为服务名称?
How do you get lsof
to produce numeric port information instead of attempting to resolve the port to service name?
例如,如果我根本不想再在lsof
打印输出中看到另一个服务名称,我希望TCP *:http (LISTEN)
给予我TCP *:80 (LISTEN)
实际信息.因此,如果有一种方法可以将数字端口设置为默认端口,那么我也想了解如何做到这一点.
For example, I want TCP *:http (LISTEN)
to give me TCP *:80 (LISTEN)
in-fact if at all possible I never want to see another service name in lsof
print-out ever again. So if there is a way to make numeric ports the default I would like to understand how to do that as well.
推荐答案
运行lsof -P
.根据 man lsof
,-P
禁止将端口号转换为端口名网络文件.禁止转换可能会使lsof运行更快.当端口名称查找无法正常工作时,它也很有用."
Run lsof -P
. According to man lsof
, -P
inhibits the conversion of port numbers to port names for network files. Inhibiting the conversion may make lsof run a little faster. It is also useful when port name lookup is not working properly."
这篇关于lsof打印数字端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!