linux中netstat和ss的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11763376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
difference between netstat and ss in linux?
提问by daehee
In linux, netstat command tells us information of active sockets in system.
在 linux 中,netstat 命令告诉我们系统中活动套接字的信息。
I understand that netstat
uses /proc/net/tcp
to acquire the system network information.
据我所知,netstat
用于/proc/net/tcp
获取系统网络信息。
Since netstat
man page says that netstat is obsolete, so we should use 'ss'.
由于netstat
手册页说 netstat 已过时,所以我们应该使用 'ss'。
NOTE
This program is obsolete. Replacement for netstat is ss. Replacement
for netstat -r is ip route. Replacement for netstat -i is ip -s link.
Replacement for netstat -g is ip maddr.
I have discovered that ss
performs similar functionality but it does not use
/proc/net/tcp
to acquire system network information.
我发现它ss
执行类似的功能,但它不
/proc/net/tcp
用于获取系统网络信息。
Now I am curious how ss
gets system network socket information?
现在我很好奇如何ss
获取系统网络套接字信息?
采纳答案by ggiroux
回答by Mr.Cool
ss
is included in iproute2 package and is the substitute of the netstat
. ss
is used to dump socket statistics. It shows information similar to netstat
. It can display more TCP and state information than other tools. It is a new, incredibly useful and faster (compared to netstat) tool for tracking TCP connections and sockets.
ss
包含在 iproute2 包中,是netstat
. ss
用于转储套接字统计信息。它显示的信息类似于netstat
。它可以显示比其他工具更多的 TCP 和状态信息。它是一种新的、非常有用且速度更快(与 netstat 相比)的工具,用于跟踪 TCP 连接和套接字。
回答by Mahesh Neelakanta
Check out the source for ss:
查看ss的来源:
https://github.com/shemminger/iproute2/blob/master/misc/ss.c
https://github.com/shemminger/iproute2/blob/master/misc/ss.c
Basically it directly queries the kernel and can respond much faster that netstat.
基本上它直接查询内核并且可以比netstat更快地响应。
回答by prosti
ss
is a utility used to investigate sockets in Linux and Unix systems. It shows information similar to netstat
and able to dump socket statistics.
ss
是用于研究 Linux 和 Unix 系统中的套接字的实用程序。它显示类似于netstat
并能够转储套接字统计信息的信息。
But netstat
cannot be replaced full by ss
. Some netstat
commands correspond better to ip
command.
但netstat
不能完全替换为ss
。有些netstat
命令更符合ip
命令。
$ netstat -r replaced by $ ip route
$ netstat -i replaced by $ ip -s lin
$ netstat -g replaced by $ ip maddr
I would say the "older" netstat
command can be replaced with both ss
and ip
commands.
我会说“旧”netstat
命令可以同时替换为ss
和ip
命令。
回答by int_ua
I've made a comparison table (in Google Docs)(light HTML link) for converting between netstat
and ss
arguments. It's too big to include and update it here.
我制作了一个比较表(在 Google Docs 中)(轻量级 HTML 链接)用于在netstat
和ss
参数之间进行转换。它太大了,无法在此处包含和更新。
The short version of difference between short arguments is:
短参数之间差异的简短版本是:
Arguments that require attention:
r N i g M W T v C F c A U 2 f
需要注意的参数:
r N i g M W T v C F c A U 2 f
Arguments that are safe to leave as is:
h V l a n Z s p e o 4 6 x t u S w
可以安全离开的参数:
h V l a n Z s p e o 4 6 x t u S w