How to do it...

When determining what's running on a server, you usually want to know if anything is listening on for connections and on what ports.

Out of the box, socket statistics (ss) is usually available. The older program, netstat, might be installed sometimes too, though it won't be covered here.

A good first step is to run ss -tua, which will list all TCP and UDP sockets:

$ ss -tuaNetid  State      Recv-Q Send-Q                                      Local Address:Port                                                       Peer Address:Port                udp    UNCONN     0      0                                               127.0.0.1:323                                                                   *:*                    udp    UNCONN     0      0                                                       *:bootpc                                                                *:*                    udp    UNCONN     0      0                                                       *:bootpc                                                                *:*                    udp    UNCONN     0      0                                                       *:sunrpc                                                                *:*                    udp    UNCONN     0      0                                                       *:ntp                                                                   *:*                    udp    UNCONN     0      0                                                       *:728                                                                   *:*                    udp    UNCONN     0      0                                                     ::1:323                                                                  :::*                    udp    UNCONN     0      0                                                      :::sunrpc                                                               :::*                    udp    UNCONN     0      0                                                      :::728                                                                  :::*                    tcp    LISTEN     0      5                                                       *:irdmi                                                                 *:*                    tcp LISTEN 0 128 ...

Get Linux Administration Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.