To find out which process is listening on a particular port in Linux, you can use the netstat
command. The netstat
command displays a list of active network connections, including the protocol, the local and remote addresses, and the state of the connection.
To see which processes are listening on a particular port, use the netstat
command with the -nlp
options and the grep
command to filter the output:
$ netstat -nlp | grep :<port number>
For example, to find out which process is listening on port 80 (the default HTTP port), you can use the following command:
$ netstat -nlp | grep :80
This will display a list of all the processes that are listening on port 80, along with their associated PIDs (process IDs).
You can also use the lsof
command to find out which process is using a particular port. The lsof
command lists all the open files on the system, including network sockets. To find out which process is using a particular port, use the lsof
command with the -i
option and the grep
command to filter the output:
$ lsof -i :<port number>
For example, to find out which process is using port 80, you can use the following command:
$ lsof -i :80
This will display a list of all the processes that are using port 80, along with their associated PIDs.