Sunday, December 9, 2012

Get Process ID on Port basis

To get pid (Process ID) based on port, use the following command:

lsof -i tcp:80
This will return the process ID(s) running this port.

Responding to Saad's comment below:

Add '-n' (no host names) and '-P' (no port names) option and remove tcp to get process ID without providing tcp:
lsof -n -P -i :80

1 comment:

  1. What if I don't give 'tcp'? As in, is there any way of knowing the process id based on port, if we don't know the network level protocol?

    ReplyDelete