How to Find out Which Process is Listening upon a Port

This article explains clearly on how to use lsof and netstat to find out the process running on a given port:

http://www.debian-administration.org/articles/184

To discover the process name, ID (pid), and other details you need to run:

lsof -i :port  

So to see which process is listening upon port 80 we can run:

root# lsof -i :80

To see all the ports open for listening upon the current host you can use another command netstat (contained in the net-tools package):

root# netstat -lnt

In this command, the "-l" option is to show only listening sockets. The "-n" option is to show numerical addresses instead of trying to determine symbolic host, port or user names. The "-t" option is to show only tcp sockets.