• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Check Listening Ports in Linux

1228

To Check Listening Ports in Linux

After configuring the network, checking the ports which are still listening on the network interface is one of the important things in network management and security. This article will help you to check Listening ports in Linux. Following examples help you to find listen port after network configuration.

Checking Listening Ports

Use nmap command with following option to view listening ports for TCP.

[root@node2 Desktop]# nmap -sT -O localhost
Starting Nmap 6.40 ( http://nmap.org ) at 2017-02-25 01:49 IST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0019s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 995 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
25/tcp  open  smtp
80/tcp  open  http
111/tcp open  rpcbind
631/tcp open  ipp
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.7 - 3.9
Network Distance: 0 hops

Use ss command to display all listen tcp and udp port.

[root@node2 Desktop]# ss -lntu
Netid  State      Recv-Q Send-Q               Local Address:Port                 Peer Address:Port 
tcp    UNCONN     0      0                                *:45113                           *:*     
tcp    UNCONN     0      0                                *:111                             *:*     
tcp    UNCONN     0      0                                *:123                             *:*     
.
.
.
tcp    LISTEN     0      128                             :::80                             :::*     
tcp    LISTEN     0      128                             :::22                             :::*     
tcp    LISTEN     0      128                            ::1:631                            :::*


Use netstat command to list all open ports or currently running ports including TCP and UDP in Linux.

[root@node2 Desktop]# netstat -lntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:36393           0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN    
.
.
.
udp6       0      0 :::683                  :::*                               
udp6       0      0 ::1:323                 :::*                               
udp6       0      0 :::54192                :::*


To view a list of different applications and port/protocol combination in single configuration file.

[root@node2 Desktop]# cat /etc/services | less


To view particular listening port in configuration file, run the following command

[root@node2 Desktop]# cat /etc/services | grep 80
http            80/tcp          www www-http    # WorldWideWeb HTTP
http            80/udp          www www-http    # HyperText Transfer Protocol
http            80/sctp                         # HyperText Transfer Protocol
socks           1080/tcp                        # socks proxy server
.
.
.
nimbusdb        48004/tcp               # NimbusDB Connector
nimbusdbctrl    48005/tcp               # NimbusDB Control
3gpp-cbsp       48049/tcp               # 3GPP Cell Broadcast Service Protocol


Filter the particular listen port details by its service name using netstat.

[root@node2 Desktop]# netstat -anp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      13560/httpd         
unix  3      [ ]         STREAM     CONNECTED     69292    13560/httpd   

Filter the particular listen port details by its port name using lsof.

[root@node2 Desktop]# lsof -i | grep 22
rpc.statd  2350 rpcuser    7u  IPv4  22736      0t0  UDP *:43289 
rpc.statd  2350 rpcuser    8u  IPv4  22740      0t0  TCP *:36393 (LISTEN)
rpc.statd  2350 rpcuser    9u  IPv6  22744      0t0  UDP *:54192 
rpc.statd  2350 rpcuser   11u  IPv6  22748      0t0  TCP *:35835 (LISTEN)
master     2404    root   13u  IPv4  22844      0t0  TCP localhost:smtp (LISTEN)
master     2404    root   14u  IPv6  22845      0t0  TCP localhost:smtp (LISTEN)

Also filter the listening port details by ss commands.

[root@node2 Desktop]# ss -lnt | grep 80
LISTEN     0      128                      :::80                      :::*

Tags:
elijah
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How to check the listening ports?

A

Use nmap command with following option to view listening ports for TCP:
Use nmap command with following option to view listening ports for TCP.
# nmap -sT -O localhost

Q

How can we display all listen tcp and UDP port?

A

By using this command:
# ss -lntu

Q

How can we list all open ports or currently running ports including TCP and UDP in Linux?

A

Use netstat command to list all open ports or currently running ports including TCP and UDP in Linux.
# netstat -lntu

Q

How to Filter the particular listen port details?

A

Filter the particular listen port details by its port name using lsof
# lsof -i | grep 22

Q

How to use nc command for port scanning?

A

By using this command:
nc -zv v.txvip1 80

Related Tutorials in How to Check Listening Ports in Linux

Related Tutorials in How to Check Listening Ports in Linux

How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
How to install Xrdp Server (Remote Desktop) on Oracle Linux 8.5
Oct 17, 2022
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to Install and Configure Mega in Linux
How to Install and Configure Mega in Linux
Jul 19, 2016
How to use Aureport command on Linux
How to use Aureport command on Linux
Nov 28, 2017
How to install Development tools on Linux
How to install Development tools on Linux
Jun 12, 2018
How to Install mod_ssl and SSL certificate on Oracle Linux
How to Install mod_ssl and SSL certificate on Oracle Linux
Dec 30, 2021
How to install Nextcloud on Ubuntu 22.04 version
How to install Nextcloud on Ubuntu 22.04 version
Jun 23, 2023
How to install ClipGrab in Linux
How to install ClipGrab in Linux
Jul 16, 2016

Related Forums in How to Check Listening Ports in Linux

Related Forums in How to Check Listening Ports in Linux

Linux
jayce class=
shasum command not found
May 5, 2017
Linux
stephan class=
How to list all samba users
Jan 12, 2018
pv command
muhammad class=
pvcreate command not found error
May 9, 2017
Linux
henry class=
Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
Apr 25, 2017
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
baseer class=
single command to apply setfacl for multiple user at a time
Jan 23, 2018
Linux
beulah class=
What does mean by 0 0 value in fstab file
Jan 2, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018

Related News in How to Check Listening Ports in Linux

Related News in How to Check Listening Ports in Linux

Anbox, the Android-to-Linux tool the developers have been waiting for
Anbox, the Android-to-Linux tool the developers have been waiting for
Apr 17, 2017
Linus Torvalds stops signing Linux kernel RC tarballs
Linus Torvalds stops signing Linux kernel RC tarballs
May 17, 2017
Capsule8 Launches Linux-Based Container Security Platform
Capsule8 Launches Linux-Based Container Security Platform
Feb 14, 2017
Symantec updates Management console product
Symantec updates Management console product
Nov 22, 2017
Latest Linux driver release feature seven AMD Vega
Latest Linux driver release feature seven AMD Vega
Mar 23, 2017
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
A Newer and a Faster Window Manager for Tina (Linux Mint 19.2)
Apr 9, 2019
Microsoft makes its Azure App service now available on Linux Systems
Microsoft makes its Azure App service now available on Linux Systems
Sep 7, 2017
Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Luk Van De Looverbosch ?
How to create a root ?

Hello,
How to create root@linuxhelp in Linux Mint 20.1 64-bit ?
Thanks in advance for your reply.
Best regards.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.