Mac OS X,  Mac OS X Server,  Mac Security,  Network Infrastructure,  Network Printing,  Ubuntu,  Unix,  VMware

Use Netstat To Locate What Process Is Using A Port

You’re installing software on some host. The installation goes well and then you go to access the information you need or connect to the service from another host. Wait, what’s that? Port is already in use? Crap. We’ve all been there. The quick and dirty answer: netstat. Let’s say you’re trying to use port 8080:

netstat -tuln | grep 8080

Let’s say the response is httpd. OK, let’s see where that’s located using whereis:

whereis httpd

And what kind of file is httpd:

file /usr/sbin/httpd

Which responds with:

/usr/sbin/httpd: Mach-O 64-bit executable x86_64

I guess we knew that since it had a port open, but what type of executable is this httpd you speak of, pray tell?

whatis httpd

httpd(8) – Apache Hypertext Transfer Protocol Server
Apache2::Resource(3pm) – Limit resources used by httpd children
CGI::Carp(3pm) – CGI routines for writing to the HTTPD
httpd(8) – Apache Hypertext Transfer Protocol Server

Oooohhhhh, I see now…