星空网 > 软件开发 > 操作系统

大话命令之

大话命令之—ss

ss是Socket Statistics的缩写。顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。

优势:

(1)显示更多更详细的有关TCP和连接状态的信息,(2)比netstat更快速更高效。

1 格式

    格式:ss    [option]…    [filter]

netstat 通过遍历proc来或许socket信息,ss使用netlink与内核tcp_diag模块通信获取socket信息

2 选项

    -t:tcp 协议相关

    -u:udp协议相关

    -w:裸套接字相关

    -l:listen状态的连接

    -a:所有

    -n:数字格式

    -p:相关的程序和PID

    -e:扩展的信息

    -m:内存用量

    -o:计时器信息

3 实例

(1)ss -l 显示本地打开的所有端口

[root@CentOS68 ~]# ss -l

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 *:60455 *:*

LISTEN 0 128 :::sunrpc :::*

LISTEN 0 128 *:sunrpc *:*

LISTEN 0 128 :::http :::*

LISTEN 0 128 :::ssh :::*

LISTEN 0 128 *:ssh *:*

LISTEN 0 128 127.0.0.1:ipp *:*

LISTEN 0 128 ::1:ipp :::*

LISTEN 0 100 ::1:smtp :::*

LISTEN 0 100 127.0.0.1:smtp *:*

LISTEN 0 128 :::39546 :::*

[root@CentOS68 ~]#

(2)ss –pl 显示每个进程具体打开的socket

[root@CentOS68 ~]# ss -pl

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 *:60455 *:* users:(("rpc.statd",1644,9))

LISTEN 0 128 :::sunrpc :::* users:(("rpcbind",1601,11))

LISTEN 0 128 *:sunrpc *:* users:(("rpcbind",1601,8))

LISTEN 0 128 *:ssh *:* users:(("sshd",1841,3))

LISTEN 0 128 127.0.0.1:ipp *:* users:(("cupsd",1679,7))

LISTEN 0 128 ::1:ipp :::* users:(("cupsd",1679,6))

LISTEN 0 100 ::1:smtp :::* users:(("master",1955,13))

LISTEN 0 100 127.0.0.1:smtp *:* users:(("master",1955,12))

LISTEN 0 128 :::39546 :::* users:(("rpc.statd",1644,11))

(3)-t -a 显示所有tcp socket

[root@CentOS68 ~]# ss -t -a

State Recv-Q Send-Q Local Address:Port Peer Address:Port

LISTEN 0 128 *:60455 *:*

LISTEN 0 128 :::sunrpc :::*

LISTEN 0 128 *:sunrpc *:*

LISTEN 0 128 :::http :::*

LISTEN 0 128 :::ssh :::*

LISTEN 0 128 *:ssh *:*

LISTEN 0 128 127.0.0.1:ipp *:*

LISTEN 0 128 ::1:ipp :::*

LISTEN 0 100 ::1:smtp :::*

LISTEN 0 100 127.0.0.1:smtp *:*

LISTEN 0 128 :::39546 :::*

ESTAB 0 64 192.168.29.68:ssh 192.168.29.1:50541

(4)-u -a 显示所有的udp socket

[root@CentOS68 ~]# ss -u -a

State Recv-Q Send-Q Local Address:Port Peer Address:Port

UNCONN 0 0 *:sunrpc *:*

UNCONN 0 0 *:39797 *:*

UNCONN 0 0 *:ipp *:*

UNCONN 0 0 *:928 *:*

UNCONN 0 0 *:bootpc *:*

UNCONN 0 0 127.0.0.1:972 *:*

UNCONN 0 0 :::59503 :::*

UNCONN 0 0 :::sunrpc :::*

UNCONN 0 0 :::928 :::*

(5)ss -o 显示所有已建立的连接

[root@CentOS68 ~]# ss -o

State Recv-Q Send-Q Local Address:Port Peer Address:Port

ESTAB 0 64 192.168.29.68:ssh 192.168.29.1:50541 timer:(on,442ms,0)




原标题:大话命令之

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

创业7年复盘,中美企业服务市场差异浅析:https://www.kjdsnews.com/a/1836614.html
SEOer不能错过的60项数据(2023版):https://www.kjdsnews.com/a/1836615.html
简单谈谈央企数科公司的真实情况:https://www.kjdsnews.com/a/1836616.html
如何通过外链分析洞悉竞品的营销策略?:https://www.kjdsnews.com/a/1836617.html
上海企业必应bing国内广告推广如何开户?:https://www.kjdsnews.com/a/1836618.html
美国计划禁止云计算厂商为中国训练AI大模型,我的一点看法:https://www.kjdsnews.com/a/1836619.html
特点有哪些?债券的定义?:https://www.vstour.cn/a/404251.html
为啥很多农村都成为了空心村,未来农村该何去何从?:https://www.vstour.cn/a/404252.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流