I have a specific PID and my question is how can I know which port belongs to that PID. Any tips on how to know the port of a service that has a specific PID? Thanks a lot.
1 Answer
One can use lsof with the -i (only list IPv4/6), -P (no port names), and -n (no hostnames) arguments, and then grep the PID:
sudo lsof -i -P -n | grep <PID>
This will present you with all ports the service might be using.