大话命令之--ss
大話命令之—ss
ss是Socket Statistics的縮寫。顧名思義,ss命令可以用來(lái)獲取socket統(tǒng)計(jì)信息,它可以顯示和netstat類似的內(nèi)容。
優(yōu)勢(shì):
(1)顯示更多更詳細(xì)的有關(guān)TCP和連接狀態(tài)的信息,(2)比netstat更快速更高效。
1 格式
????格式:ss????[option]…????[filter]
netstat 通過(guò)遍歷proc來(lái)或許socket信息,ss使用netlink與內(nèi)核tcp_diag模塊通信獲取socket信息
2 選項(xiàng)
????-t:tcp 協(xié)議相關(guān)
????-u:udp協(xié)議相關(guān)
????-w:裸套接字相關(guān)
????-l:listen狀態(tài)的連接
????-a:所有
????-n:數(shù)字格式
????-p:相關(guān)的程序和PID
????-e:擴(kuò)展的信息
????-m:內(nèi)存用量
????-o:計(jì)時(shí)器信息
3 實(shí)例
(1)ss -l 顯示本地打開(kāi)的所有端口
[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 顯示每個(gè)進(jìn)程具體打開(kāi)的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)
轉(zhuǎn)載于:https://www.cnblogs.com/Sunzz/p/7230985.html
總結(jié)
- 上一篇: 蚊子为什么喜欢在黑暗的地方吸血呢?
- 下一篇: 我是玉龙路良种繁育中心院内住户夏小安,现