How to check listening ports with netstat

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
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To: Back Up MySQL Databases From The Command Line

While automated backups are important, sometimes you just want to take a quick and dirty snapshot...

How To Install MariaDB on CentOS 6

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and...

How to Display (List) All Jobs in Cron / Crontab

View Root’s Cron Jobs crontab -l  View a User’s Cron Jobs crontab -u username -l Example with...

How To: Automate Server Scripts With Cron

Servers can automatically perform tasks that you would otherwise have to perform yourself, such...

How to find sending spam emails and enable mail header in php.ini

- In Linux servers if there are a lot of emails in the queue "over 100" emails. you can check if...