$manlookup

ss

(8)

another utility to investigate sockets

ss [options] [ FILTER ]

Options

46
-h--help

Show summary of options.

-V--version

Output version information.

-H--no-header

Suppress header line.

-Q--no-queues

Suppress sending and receiving queue columns.

-O--oneline

Print each socket's data on a single line.

-n--numeric

Do not try to resolve service names. Show exact bandwidth values, instead of human-readable.

-r--resolve

Try to resolve numeric address/ports.

-a--all

Display both listening and non-listening (for TCP this means established connections) sockets.

-l--listening

Display only listening sockets (these are omitted by default).

-B--bound-inactive

Display only TCP bound but inactive (not listening, connecting, etc.) sockets (these are omitted by default).

-o--options

Show timer information. For TCP protocol, the output format is:

-e--extended

Show detailed socket information. The output format is:

-m--memory

Show socket memory usage. The output format is:

-p--processes

Show process using socket.

-T--threads

Show thread using socket. Implies -p.

-i--info

Show internal TCP information. Below fields may appear:

--tos

Show ToS and priority information. Below fields may appear:

--cgroup

Show cgroup information. Below fields may appear:

--tipcinfo

Show internal tipc socket information.

-K--kill

Attempts to forcibly close sockets. This option displays sockets that are successfully closed and silently skips sockets that the kernel does not support closing. It supports IPv4 and IPv6 sockets only.

-s--summary

Print summary statistics. This option does not parse socket lists obtaining summary from various sources. It is useful when amount of sockets is so huge that parsing /proc/net/tcp is painful.

-E--events

Continually display sockets as they are destroyed

-Z--context

As the -p option but also shows process security context. If the -T option is used, also shows thread security context. For netlink(7) sockets the initiating process context is displayed as follows:

-z--contexts

As the -Z option but also shows the socket context. The socket context is taken from the associated inode and is not the actual socket context held by the kernel. Sockets are typically labeled with the context of the creating process, however the context shown will reflect any policy role, type and/or range transition rules applied, and is therefore a useful reference.

-N--net

Switch to the specified network namespace name.

-b--bpf

Show socket classic BPF filters (only administrators are allowed to get these information).

-4--ipv4

Display only IP version 4 sockets (alias for -f inet).

-6--ipv6

Display only IP version 6 sockets (alias for -f inet6).

-0--packet

Display PACKET sockets (alias for -f link).

-t--tcp

Display TCP sockets.

-u--udp

Display UDP sockets.

-d--dccp

Display DCCP sockets.

-w--raw

Display RAW sockets.

-x--unix

Display Unix domain sockets (alias for -f unix).

-S--sctp

Display SCTP sockets.

--tipc

Display tipc sockets (alias for -f tipc).

--vsock

Display vsock sockets (alias for -f vsock).

--xdp

Display XDP sockets (alias for -f xdp).

-M--mptcp

Display MPTCP sockets.

--inet-sockopt

Display inet socket options.

-f--family

Display sockets of type FAMILY. Currently the following families are supported: unix, inet, inet6, link, netlink, vsock, tipc, xdp.

-A--query--socket

List of socket tables to dump, separated by commas. The following identifiers are understood: all, inet, tcp, udp, raw, unix, packet, netlink, unix_dgram, unix_stream, unix_seqpacket, packet_raw, packet_dgram, dccp, sctp, tipc, vsock_stream, vsock_dgram, xdp, mptcp. Any item in the list may optionally be prefixed by an exclamation mark (!) to exclude that socket table from being dumped.

-D--diag

Do not display anything, just dump raw information about TCP sockets to FILE after applying filters. If FILE is - stdout is used.

-F--filter

Read filter information from FILE. Each line of FILE is interpreted like single command line option. If FILE is - stdin is used.

--bpf-maps

Pretty-print all the BPF socket-local data entries for each socket.

--bpf-map-id

Pretty-print the BPF socket-local data entries for the requested map ID. Can be used more than once.

DESCRIPTION

ss is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP and state information than other tools.

STATE-FILTER

STATE-FILTER allows one to construct arbitrary set of states to match. Its syntax is sequence of keywords state and exclude followed by identifier of state.

All standard TCP states: established, syn-sent, syn-recv, fin-wait-1, fin-wait-2, time-wait, closed, close-wait, last-ack, listening and closing.

all - for all the states

connected - all the states except for listening and closed

synchronized - all the connected states except for syn-sent

bucket - states, which are maintained as minisockets, i.e. time-wait and syn-recv

big - opposite to bucket

bound-inactive - bound but otherwise inactive sockets (not listening, connecting, etc.)

EXPRESSION

EXPRESSION allows filtering based on specific criteria. EXPRESSION consists of a series of predicates combined by boolean operators. The possible operators in increasing order of precedence are or (or | or ||), and (or & or &&), and not (or !). If no operator is between consecutive predicates, an implicit and operator is assumed. Subexpressions can be grouped with "(" and ")".

The following predicates are supported:

{dst|src} [=] HOST
Test if the destination or source matches HOST. See HOST SYNTAX for details.
{dport|sport} [OP] [FAMILY:]:PORT
Compare the destination or source port to PORT. OP can be any of "<", "<=", "=", "!=", ">=" and ">". Following normal arithmetic rules. FAMILY and PORT are as described in HOST SYNTAX below.
Match based on the device the connection uses. DEVICE can either be a device name or the index of the interface.
Matches based on the fwmark value for the connection. This can either be a specific mark value or a mark value followed by a "/" and a bitmask of which bits to use in the comparison. For example "fwmark = 0x01/0x03" would match if the two least significant bits of the fwmark were 0x01.
cgroup [=|!=] PATH
Match if the connection is part of a cgroup at the given path.
Match if the port or path of the source address was automatically allocated (rather than explicitly specified).

Most operators have aliases. If no operator is supplied "=" is assumed. Each of the following groups of operators are all equivalent:

  • = == eq
  • != ne neq
  • > gt
  • < lt
  • >= ge geq
  • <= le leq
  • ! not
  • | || or
  • & && and

HOST SYNTAX

The general host syntax is [FAMILY:]ADDRESS[:PORT].

FAMILY must be one of the families supported by the -f option. If not given it defaults to the family given with the -f option, and if that is also missing, will assume either inet or inet6. Note that all host conditions in the expression should either all be the same family or be only inet and inet6. If there is some other mixture of families, the results will probably be unexpected.

The form of ADDRESS and PORT depends on the family used. "*" can be used as a wildcard for either the address or port. The details for each family are as follows:

ADDRESS is a glob pattern (see fnmatch(3)) that will be matched case-insensitively against the unix socket's address. Both path and abstract names are supported. Unix addresses do not support a port, and "*" cannot be used as a wildcard.
ADDRESS is the case-insensitive name of an Ethernet protocol to match. PORT is either a device name or a device index for the desired link device, as seen in the output of ip link.
ADDRESS is a descriptor of the netlink family. Possible values come from /etc/iproute2/nl_protos. PORT is the port id of the socket, which is usually the same as the owning process id. The value "kernel" can be used to represent the kernel (port id of 0).
ADDRESS is an integer representing the CID address, and PORT is the port.
ADDRESS is an ip address (either v4 or v6 depending on the family) or a DNS hostname that resolves to an ip address of the required version. An ipv6 address must be enclosed in "[" and "]" to disambiguate the port separator. The address may additionally have a prefix length given in CIDR notation (a slash followed by the prefix length in bits). PORT is either the numerical socket port, or the service name for the port to match.

USAGE EXAMPLES

Display all TCP sockets.
Display all TCP sockets with process SELinux security contexts.
Display all UDP sockets.
Display all established ssh connections.
Find all local processes connected to X server.
List all the tcp sockets in state FIN-WAIT-1 for our apache to network 193.233.7/24 and look at their timers.
List sockets in all states from all socket tables but TCP.

AUTHOR

ss was written by Alexey Kuznetsov, kuznet@ms2.inr.ac.ru.

This manual page was written by Michael Prokop mika@grml.org for the Debian project (but may be used by others).

See also