Networking

Linux ss command

Show socket information. The flags below list listening TCP and UDP ports.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

ss [OPTIONS] [FILTER]

Examples

Show listening TCP/UDP sockets and associated processes.

ss -tulpn

List established TCP connections numerically.

ss -tan state established

Parameters, options and clauses

Option / clauseDescription
-t, --tcpDisplay TCP sockets.
-u, --udpDisplay UDP sockets.
-l, --listeningDisplay listening sockets.
-n, --numericDo not resolve service names or addresses.
-p, --processesShow the process using each socket (permissions may limit details).
-a, --allDisplay listening and non-listening sockets.
-s, --summaryPrint socket usage summary.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory