How to see listening ports and processes

You can list the processes and the sockets (address:port combination) by using this simple syntax of the ss command:

ss -tulnp

The -t flag is for showing TCP ports

The -u is for UDP ports (you can reduce the output by choosing only one of the protocols – TCP or UDP)

Next flag -l is to display only the listening sockets

For a numbers only output we add the -n flag

And -p stand for showing the processes names

The example command output;

root@cbnet:~# ss -tulnp
Netid  State   Recv-Q  Send-Q        Local Address:Port   Peer Address:Port Process
udp    UNCONN  0       0             127.0.0.53%lo:53          0.0.0.0:*     users:(("systemd-resolve",pid=670,fd=12))
udp    UNCONN  0       0        78.130.176.254%eth0:68          0.0.0.0:*     users:(("systemd-network",pid=665,fd=19))
tcp    LISTEN  0       4096          127.0.0.53%lo:53          0.0.0.0:*     users:(("systemd-resolve",pid=670,fd=13))
tcp    LISTEN  0       128                 0.0.0.0:22          0.0.0.0:*     users:(("sshd",pid=747,fd=3))
tcp    LISTEN  0       128                    [::]:22             [::]:*     users:(("sshd",pid=747,fd=4))
root@cbnet:~#