大话命令之–ss

大话命令之—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)

原创文章,作者:linux is not unix,如若转载,请注明出处:http://www.178linux.com/75700

(10)
linux is not unixlinux is not unix
上一篇 2017-05-15 14:09
下一篇 2017-05-15 14:10

相关推荐

  • LAMP基于编译安装方式实现(httpd与php以fastcgi方式结合)3

    概述     在某些现有rpm包不能满足需求的时候,可能需要编译安装LAMP环境,本篇就介绍下php与httpd结合方式为fastcgi方式结合时的编译安装,同时,由于httpd与php以module方式结合时,仅是编译选项有所差别,故也会简单说明下编译选项的差异 环境     CentOS7系统,…

    Linux干货 2016-10-17
  • Linux 的发展史

    前言 l  免费源码开放 l  安全性高,漏洞修补快 l  多任务、多使用者 l  多平台支持 l  设备要求低,不耗资源 ……      看到这一系列的优点,在IT人的脑海里只会浮出一个名字Linux. 如果还不够直观的话,有这么一个数据, 显示前500系统中的485…

    Linux干货 2016-10-14
  • Python内置数据结构

    Python内置数据结构 数值型 Int,float,complex,bool 序列对象 字符串:str  列表:list   数组:tuple 键值对 集合:set    字典:dict 数值型 Int,float,complex,bool都是class,1,5.0,2+3j都是对象即示例 Int:python3的int就是长整形,且没有大小限制,受限于内…

    Linux干货 2018-03-26
  • psql: undefined symbol: PQconnectdbParams 已解决

    操作PostgreSQL的过程中,在执行psql的时候,遇到了如下错误:  /path/to/postgresql/bin/psql: symbol lookup error: /usr/pgsql-9.2/bin/psql: undefined symbol: PQconnectdbParams 整理后发现是,PostgreSQL的动态链接库没有…

    Linux干货 2015-03-08
  • Openssl——为你的信息保驾护航

    OpenSSL基础 ·传输层协议:TCP,UDP,SCTP         port:进程地址,进程向内核注册使用某端口(独占) ·同一主机上的进程间通信:IPC,message queue,shm,semerphor ·不同主机上的进程间通信:socket  &nbs…

    Linux干货 2016-09-22
  • lvs集群学习笔记之原理

    lvs集群学习笔记之原理 lvs集群学习笔记之原理 集群 负载均衡 lvs 原理 lvs集群学习笔记之原理 什么是集群 什么是负载均衡 负载均衡解决方案 lvs简介 lvs内核空间模型 lvs特点 lvs实现方式 lvs实现方式之nat模型 lvs实现方式之dr lvs实现方式之tun lvs实现方式之FULLNAT lvs之算法 静态算法   &…

    Linux干货 2017-01-03