lsof print numeric ports

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-09 20:01:08

问题


How do you get lsof to produce numeric port information instead of attempting to resolve the port to service name?

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.


回答1:


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."




回答2:


Sometimes handy is:

lsof -Pi

When I tried losf -iP it gave me some trash, so make sure P goes first.


As a side note: lsof -3.14 will provide the same trash, don't try this.



来源:https://stackoverflow.com/questions/34032299/lsof-print-numeric-ports

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!