Linux Command - ss

ss - another utility to investigate sockets

ss is used to dump socket statistics.

Options

Syntax

1
ss [options] [ FILTER ]

When no option is used ss displays a list of open non-listening sockets (e.g. TCP/UNIX/UDP) that have established connection.

option description
-t, –tcp Display TCP sockets.
-u, –udp Display UDP sockets.
-l, –listening Display only listening sockets (these are omitted by default).
-p, –processes Show process using socket.
-n, –numeric Do not try to resolve service names. Show exact bandwidth values, instead of human-readable.

Examples

Display all TCP sockets.

1
ss -t -a

Finding the PID of the process using a specific port. Here we use a filter to filter by port number. You can then kill the process using kill command.

1
ss -lpn 'sport = :8080'

Reference