ss 命令学习

1、统计服务器并发连接数(ss性能 > netstat)
     time netstat -ant |grep EST|wc -l
     time ss -o state established | wc -l

     为什么ss比netstat快:
netstat是遍历/proc下面每个PID目录,ss直接读/proc/net下面的统计信息。所以ss执行的时候消耗资源以及消耗的时间都比netstat少很多


2、 显示本地打开的所有端口
    ss -l

3、显示每个进程具体打开的socket
    ss -pl 
   看当前机器的11001端口被谁占用了
       ss -lp src :11001

4、显示所有tcp socket
    ss -t -a 

5、显示所有的UDP Socekt    
    ss -u -a 

6、显示所有已建立的SMTP连接
    ss -o state established `( dport = :smtp or sport = :smtp )`

7、显示所有已建立的HTTP连接(包含对外提供的80,以及访问外部的80)
    ss -o state established `( dport = :http or sport = :http )`

8、显示处在FIN-WAIT-1状态的http、https连接
    ss -o state fin-wait-1 '( sport = :http or sport = :https )'
        ss常用的state状态:
        established
        syn-sent
        syn-recv
        fin-wait-1
        fin-wait-2
        time-wait
        closed
        close-wait
        last-ack
        listen
        closing
        all : All of the above states
        connected : All the states except for listen and closed
        synchronized : All the connected states except for syn-sent
        bucket : Show states, which are maintained as minisockets, i.e. time-wait and syn-recv.
        big : Opposite to bucket state.
        established
        syn-sent
        syn-recv
        fin-wait-1
        fin-wait-2
        time-wait
        closed
        close-wait
        last-ack
        listen
        closing
        all : All of the above states
        connected : All the states except for listen and closed
        synchronized : All the connected states except for syn-sent
        bucket : Show states, which are maintained as minisockets, i.e. time-wait and syn-recv.
        big : Opposite to bucket state.
9、    找出所有连接X服务器的进程
    ss -x src /tmp/.X11-unix/* 

10、列出当前socket详细信息:
    ss -s 

11、列出本地哪个进程连接到x server
    ss -x src /tmp/ X11-unix/*

12、列出来至120.33.31.1,80端口的连接
    ss src 120.33.31.1:http
    ss src 120.33.31.1:80

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值