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

相关推荐

  • 第二天上课 llinux发展史

                             linux发展史 unix诞生    1965年时,贝尔实验室(Bell Labs)加入一项由通用电气(General Electric)和麻省理工学院(MIT…

    Linux干货 2016-10-18
  • 推荐-常用RAID级别详解

    一、RAID是什么       RAID(Redundant Arrays of Indent Disks)的名称是独立磁盘冗余阵列,是一种通过将多块硬盘按照某种特定的结构组织起来当做一块硬盘来使用的技术,多块硬盘不同的组织结构我们称之为RAID的级别。而RAID技术的特性主要表现在两个方面: (1)提高硬盘…

    Linux干货 2016-03-27
  • 26期全程班-第三周博客作业

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。     # who | cut -d” ” -f 1 | sort -u   2、取出最后登录到当前系统的用户的相关信息。     # id `last …

    Linux干货 2017-02-18
  • 用户相关属性权限、正则表达式的应用(网络班21期第四周博客)

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。          mkdir /home/tuser1        &n…

    Linux干货 2016-08-02
  • 编译安装apache

    编译安装apache可简单分为3步: 第一步:下载apache软件包解决依赖关系并生成Makefile 1.首先准备开发环境,可以通过yum安装开发包组:yum groupinstall Development Tools 2.准备apache软件包,可以通过http://httpd.apache.org下载到本地。随后解包tar -xf httpd-2.4…

    Linux干货 2017-12-03