Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application path and listening port

Tags:

linux

port

listen

I'd like to know which application that is listening on a port on a linux machine.

There are multiple servers, apache and what not on a single machine and I'd like to know which server is listening on which port without having to dig through the configuration files of each server.

Is there a command that lists the path to the executable and which port it is listening on?

like image 551
bucabay Avatar asked Feb 01 '10 18:02

bucabay


2 Answers

netstat -t -l -p will list the listening ports and the pid and process name that created the socket. Since you have the pid you can use ps PID to find the path to the executable.

like image 180
Geoff Reedy Avatar answered Oct 04 '22 03:10

Geoff Reedy


Also lsof -i:<port number> should give you the PID of the process and you can use ps <pid> to look up for the path

like image 33
Ganesh Krishnan Avatar answered Oct 04 '22 03:10

Ganesh Krishnan