Check ports
To list the TCP ports that are being listened on, and the name of each listener’s daemon and its PID, run the following command:
sudo netstat -plnt
The following example shows the output for three common programs that are listening on three different sockets.
$ sudo netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3686/mysqld
tcp 0 0 :::443 :::* LISTEN 2218/httpd
tcp 0 0 :::80 :::* LISTEN 2218/httpd
tcp 0 0 :::22 :::* LISTEN 1051/sshd
Filter the list
If the list of listening daemons is long, you can use grep
to filter it. For example, to filter out everything except the default web server port 80
, run the following command:
$ sudo netstat -plnt | grep ':80'
tcp 0 0 :::80 :::* LISTEN 8448/httpd