How to check if port is Listening

  • Home
  • /
  • How to check if port is Listening
How to check if port is Listening

How to check if port is Listening

Linux 01 Jun 2020 Siva Nadesan

In this article we will go over few options to check if a port is open in Linux machine

Using lsop

Command : sudo lsof -i -P -n | grep LISTEN
Output :

systemd-r    671    systemd-resolve   13u  IPv4    38126      0t0  TCP 127.0.0.53:53 (LISTEN)
mongod      1207            mongodb   11u  IPv4    52227      0t0  TCP *:27017 (LISTEN)
container   1318               root    8u  IPv4    46101      0t0  TCP 127.0.0.1:32933 (LISTEN)
dockerd     1599               root    3u  IPv6    49803      0t0  TCP *:2375 (LISTEN)
postgres    1624           postgres    5u  IPv4    47429      0t0  TCP *:5432 (LISTEN)
postgres    1624           postgres    6u  IPv6    47430      0t0  TCP *:5432 (LISTEN)
java        2202            jenkins  163u  IPv6    56411      0t0  TCP *:8080 (LISTEN)
Using netstat

Command : netstat -nlt
Output :

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:32933         0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN
tcp6       0      0 :::8083                 :::*                    LISTEN
Using nmap

Command : sudo nmap -sT -O localhost
Output :

Starting Nmap 7.60 ( https://nmap.org ) at 2020-06-21 21:38 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000062s latency).
Not shown: 992 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
631/tcp  open  ipp
5432/tcp open  postgresql
8080/tcp open  http-proxy
8081/tcp open  blackice-icecap
8082/tcp open  blackice-alerts
8083/tcp open  us-srv
8088/tcp open  radan-http


About The Authors
Siva Nadesan

Siva Nadesan is a Principal Data Engineer. His passion includes data and blogging about technologies. He is also the creator and maintainer of www.entechlog.com

LinkedIn

Share: