Linux 的netstat -n怎么理解

netstat命令用来打印Linux中网络系统的状态信息,可让你得知整个Linux系统的网络情况
当你不想让主机,端口和用户名显示,使用netstat -n。将会使用数字代替那些名称

我试了下:
先使用netstat -a 命令,其结果如下图:
图片描述

localhost:6379应该是Redis的

然后我使用netstat -an命令,其结果如下图:
![图片描述][2]

确实使用数字代替了名称,可是6379的端口号还是存在,这和他的不显示端口矛盾了?怎么理解??

阅读 4.2k
2 个回答

n选项是 以数字形式显示地址和端口号,而不是以名称显示。
进一步就是用IP地址而不是主机名(对hosts中记录的主机),对于一些默认端口也直接显示端口数字,而不是用服务名称,比如
ssh服务是22,web服务是80,web-ssl是443等等。

-n 是数字化显示的意思

以下引自man netstat

--numeric, -n

   Show numerical addresses instead of trying to determine symbolic host, port or user names. 显示数字地址, 而不是尝试确定主机、端口或用户名的符号名称。

类似的还有

--numeric-hosts

   shows numerical host addresses but does not affect the resolution of port or user names.

--numeric-ports

   shows numerical port numbers but does not affect the resolution of host or user names.

--numeric-users

   shows numerical user IDs but does not affect the resolution of host or port names.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题