Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
InfrastructureMiddleOccasionalTroubleshooting

How do you determine which process is listening on a TCP port in Linux and Windows?

Answer

On Linux, `ss -lntp` is a common way to list listening TCP sockets and associated processes when permissions allow; `lsof -i` may also help where installed. On Windows, `netstat -ano` shows listening connections with PIDs, which can be mapped with `tasklist`; PowerShell can use `Get-NetTCPConnection` plus process inspection.

Strong answer includes

  • Linux ss can map listeners to processes
  • Windows netstat -ano exposes PIDs
  • maps the PID to the owning process before taking action

Practical example

If port 8080 is unexpectedly occupied, use `ss -lntp | grep ':8080'` on Linux or `netstat -ano | findstr :8080` on Windows, then identify the PID before stopping anything.

#linux#windows#networking#ports#processes

Sources

Linux man-pages projectman7.org / Linux man-pages project · Linux processes, signals, networking and system-call-facing command behaviorWindows commands referenceMicrosoft · Command Prompt utilities including ipconfig, netstat, tasklist, taskkill, sc, findstr, ping, tracert and nslookupPowerShell documentationMicrosoft · PowerShell cmdlets, object pipeline, processes, services, networking, event logs and environment handling