SHELL 003 -- ss命令常用方法

1.查看指定端口/服务是否正常运行
   ss -anp|grep  端口号/服务名
   eg:
[root@LNP]~# ss -anp|grep 111
LISTEN     0      128                      :::111                     :::*      users:(("rpcbind",1221,11))
LISTEN     0      128                       *:111                      *:*      users:(("rpcbind",1221,8))
[root@LNP]~# ss -an|grep 111
LISTEN     0      128                      :::111                     :::*     
LISTEN     0      128                       *:111                      *:*     
[root@LNP]~# ss -anp|grep rpcbind
LISTEN     0      128                      :::111                     :::*      users:(("rpcbind",1221,11))
LISTEN     0      128                       *:111                      *:*      users:(("rpcbind",1221,8))
[root@LNP]~# ss -ap|grep rpcbind
LISTEN     0      128                    :::sunrpc                  :::*        users:(("rpcbind",1221,11))
LISTEN     0      128                     *:sunrpc                   *:*        users:(("rpcbind",1221,8))
   加n参数,才能使用端口号进行查询, n表示不 转换端口号为TCP/UDP对应的服务名
   加p差数,才能使用服务名进行查询p列出对应的应用名称和进程号

2.查看当前服务器网络连接汇总信息
   ss -s
   eg: 
[root@LNP]~# ss -s
Total: 436 (kernel 437)
TCP:   13 (estab 1, closed 0, orphaned 0, synrecv 0, timewait 0/0), ports 8

Transport Total     IP        IPv6
*         437       -         -        
RAW       0         0         0        
UDP       8         5         3        
TCP       13        8         5        
INET      21        13        8        
FRAG      0         0         0  
   用做大量socket连接时宏观统计

3.查看当前服务器所有LISTEN状态socket连接
   ss -l
   eg:
[root@LNP]~# ss -l 
State      Recv-Q Send-Q                                        Local Address:Port                                            Peer Address:Port   
LISTEN     0      128                                                      :::37829                                                     :::*       
LISTEN     0      128                                               127.0.0.1:cslistener                                                    *:*       
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                                                       *:33850                                                      *:*   

4.查看当前服务器所有的socket连接
   ss -a
   eg:
[root@LNP]~# ss -a
State      Recv-Q Send-Q                                        Local Address:Port                                            Peer Address:Port   
LISTEN     0      128                                                      :::37829                                                     :::*       
LISTEN     0      128                                               127.0.0.1:cslistener                                                    *:*       
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                                                       *:33850                                                      *:*       
ESTAB      0      52                                           192.168.217.14:ssh                                            192.168.217.1:59342 
    如果只想查看TCP、UDP、RAW、UNIX、DCCP对应的socket,分别用-ta、-ua、-wa、-xa、-da
    eg:
[root@LNP]~# ss -ta
State      Recv-Q Send-Q                                        Local Address:Port                                            Peer Address:Port   
LISTEN     0      128                                                      :::37829                                                     :::*       
LISTEN     0      128                                               127.0.0.1:cslistener                                                    *:*       
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                                                       *:33850                                                      *:*       
ESTAB      0      52                                           192.168.217.14:ssh                                            192.168.217.1:59342   
[root@LNP]~# ss -ua
State      Recv-Q Send-Q                                        Local Address:Port                                            Peer Address:Port   
UNCONN     0      0                                                 127.0.0.1:1001                                                       *:*       
UNCONN     0      0                                                         *:sunrpc                                                     *:*       
UNCONN     0      0                                                         *:ipp                                                        *:*       
UNCONN     0      0                                                         *:33471                                                      *:*       
UNCONN     0      0                                                         *:972                                                        *:*       
UNCONN     0      0                                                        :::sunrpc                                                    :::*       
UNCONN     0      0                                                        :::39823                                                     :::*       
UNCONN     0      0                                                        :::972                                                       :::*   


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值