Determine process using a port, without sudo

Posted by pat on Server Fault See other posts from Server Fault or by pat
Published on 2011-05-08T13:47:11Z Indexed on 2012/08/30 21:41 UTC
Read the original article Hit count: 243

Filed under:
|
|
|

I'd like to find out which process (in particular, the process id) is using a given port. The one catch is, I don't want to use sudo, nor am I logged in as root. The processes I want this to work for are run by the same user that I want to find the process id - so I would have thought this was simple.

Both lsof and netstat won't tell me the process id unless I run them using sudo - they will tell me that the port is being used though.

As some extra context - I have various apps all connecting via SSH to a server I manage, and creating reverse port forwards. Once those are set up, my server does some processing using the forwarded port, and then the connection can be killed. If I can map specific ports (each app has their own) to processes, this is a simple script. Any suggestions?

This is on an Ubuntu box, by the way - but I'm guessing any solution will be standard across most Linux distros.

© Server Fault or respective owner

Related posts about linux

Related posts about ubuntu