How to find out which process is listening on a given TCP/UDP port?

On GNU/Linux systems, one way to see which ports some program is listening to, is to use the ss command like this:

$ ss -tl
State                    Recv-Q                   Send-Q                                     Local Address:Port                                       Peer Address:Port                  Process                   

where “t” is for TCP (use u for UDP) and “l” is for “listening”, I think.

As I understand it, each line of the output from such a command gives info about one process that is currently listening on a certain port. However, the rightmost column “Process” seems always empty, for some reason. I would like to know which program/process is listening, so that I can decide if it should really be there or if it something unnecessary that should be removed.

How to find out which process is listening on a given port?

Maybe it is just ephemeral, you actually have to do the command when something is actively listening?

In other words, then something is passive, you don’ t see it? (Because it ain’t there.)

How about:
lsof -i


1 Like

ss -laputen should give you everything you need :slight_smile:


And ss -lilliputen is in smaller format (humor).

1 Like

Ha ha very funny. Looks like the “e” flag is the one needed to make ss show which process (or service) is responsible. If I do this:

ss -tle

then it shows the services listening on some ports, in my case the responsible services were cups (printing system) and systemd-resolved (Network Name Resolution manager).

Mystery solved. Thanks for all suggestions and jokes!