Use `ss` To Determine What Process Is Using a Port
Here’s the situation: You need to determine what process is listening on a specific network port. The port could be used for TCP, UDP or other network protocol.
Solution
Use the ss
command to determine which ports are in use, then narrow the
output by the port.
Procedure
In this example, the port in question will be 1313
. It will be used in the
commands shown. Replace this value with the port of interest in the specific
use case.
Step 1. Run ss
with the appropriate expression
sudo ss -l -p -n "sport = 1313"
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.1:1313 0.0.0.0:* users:(("hugo",pid=273360,fd=3))
The last column indicates the name of the command and its process id.
Reference
Tags: