Linux-ss各命令詳解
ss -l 顯示本地打開的所有端口
ss -pl 顯示每個進程具體打開的socket
ss -t -a 顯示所有tcp socket
ss -u -a 顯示所有的UDP Socekt
ss -o state established '( dport = :smtp or sport = :smtp )' 顯示所有已建立的SMTP連接
ss -o state established '( dport = :http or sport = :http )' 顯示所有已建立的HTTP連接
ss -x src /tmp/.X11-unix/* 找出所有連接X服務器的進程
ss -s 列出當前socket詳細信息:
解釋:netstat是遍歷/proc下面每個PID目錄,ss直接讀/proc/net下面的統計信息。所以ss執行的時候消耗資源以及消耗的時間都比netstat少很多
Usage: ss [ OPTIONS ]
ss [ OPTIONS ] [ FILTER ]
-h, --help this message
-V, --version output version information
-n, --numeric don't resolve service names
-r, --resolve resolve host names
-a, --all display all sockets
-l, --listening display listening sockets
-o, --options show timer information
-e, --extended show detailed socket information
-m, --memory show socket memory usage
-p, --processes show process using socket
-i, --info show internal TCP information
-s, --summary show socket usage summary
-4, --ipv4 display only IP version 4 sockets
-6, --ipv6 display only IP version 6 sockets
-0, --packet display PACKET sockets
-t, --tcp display only TCP sockets
-u, --udp display only UDP sockets
-d, --dccp display only DCCP sockets
-w, --raw display only RAW sockets
-x, --unix display only Unix domain sockets
-f, --family=FAMILY display sockets of type FAMILY
-A, --query=QUERY
QUERY := {all|inet|tcp|udp|raw|unix|packet|netlink}[,QUERY]
-F, --filter=FILE read filter information from FILE
FILTER := [ state TCP-STATE ] [ EXPRESSION ]