Find the Process Listening on a Port
Objective
Determine which process is listening on a specific network port.
Prerequisites
- Shell access to the Linux host.
- Permissions to inspect network sockets and process information (typically root for unprivileged processes).
Procedure
-
Use
ssto list sockets bound to the port:ss -tlnp | grep ':<port>' -
If
ssis unavailable, usenetstat:netstat -tlnp | grep ':<port>' -
Extract the process ID from the output and inspect the process:
ps -fp <pid> -
For UDP ports, replace
-twith-u:ss -ulnp | grep ':<port>'
Verification
- Confirm the PID in the
ssornetstatoutput matches the expected service. - Verify the service is functional using its native health check or by connecting to the port.