• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

To check which all ports are listening (Introducing Four Linux Commands)

Ruben Roy

  • 5 min read
To check which all ports are listening (Introducing Four Linux Commands)

Generating audio, please wait...

A port is an addressable network location implemented in an operating system to help differentiate traffic destined for different services or Applications.

The state of a port is either open, filtered, closed, or unfiltered. A port is said to be open if an application on the target machine is listening for connections/packets on that port.

In this blog, I will explain four ways to check open ports and also will show you how to find which application is listening on what port in Linux.

1. Using Netstat Command

Netstat is a widely used tool for querying information about the Linux networking subsystem. You can use it to print all open ports like this:

$ sudo netstat -ltup

The flag -l tells netstat to print all listening sockets, -t shows all TCP connections, -u displays all UDP connections and -p enables printing of application/program name listening on the port.

Please see the example given below.

sudo netstat -ltup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 localhost:ipp *:* LISTEN 737/cupsd 
tcp 0 0 *:43615 *:* LISTEN - 
tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN 737/cupsd 
tcp6 0 0 [::]:41979 [::]:* LISTEN - 
udp 0 0 *:42720 *:* 2045/openvpn 
udp 0 0 *:59161 *:* 735/avahi-daemon: r
udp 0 0 *:56671 *:* 4671/openvpn 
udp 0 0 *:ipp *:* 803/cups-browsed
udp 0 0 *:mdns *:* 735/avahi-daemon: r
udp6 0 0 [::]:39097 [::]:* 735/avahi-daemon: r
udp6 0 0 [::]:mdns [::]:*

To print numeric values rather than service names, add the -n flag.

sudo netstat -lntup

You can also use grep command to find out which application is listening on a particular port, for example.

$ sudo netstat -lntup | grep "tcp"

You can check the sample output as snippet added below.

netstat -lntup | grep "tcp"

tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 737/cupsd 

tcp 0 0 0.0.0.0:43615 0.0.0.0:* LISTEN - 

tcp6 0 0 ::1:631 :::* LISTEN 737/cupsd 

tcp6 0 0 :::41979 :::* LISTEN

2. Using ss Command

ss is another useful tool for displaying information about sockets. It’s output looks similar to that of netstat. The following command will show all listening ports for TCP and UDP connections in numeric value.

The flag -l tells ss to print all listening sockets, -t shows all TCP connections and -u displays all UDP connections listening on the port.

Please see the example given below.

$ sudo ss -lntu

Please see the sample outcome added below.

ss -lntu

Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port 

udp UNCONN 0 0 *:42720 *:* 

udp UNCONN 0 0 *:59161 *:* 

udp UNCONN 0 0 *:56671 *:* 

udp UNCONN 0 0 *:631 *:* 

udp UNCONN 0 0 *:5353 *:* 

udp UNCONN 0 0 :::39097 :::* 

udp UNCONN 0 0 :::5353 :::* 

tcp LISTEN 0 5 127.0.0.1:631 *:* 

tcp LISTEN 0 64 *:43615 *:* 

tcp LISTEN 0 5 ::1:631 :::* 

tcp LISTEN 0 64 :::41979 :::*

3. Using Nmap Command

Nmap is a powerful and popular network exploration tool and port scanner. To install nmap on your system, use your default package manager as shown.

$ sudo apt install nmap [On Debian/Ubuntu]

$ sudo yum install nmap [On CentOS/RHEL]

We can run below command to check the outcome by adding requires options.

sudo nmap -n -PN -sT -sU -p- localhost

-PN Scan a host when protected by the firewall

-sP Scan a network and find out which servers and devices are up and running

-sU Scan a host for UDP services (UDP scan)

-p Enables printing of application/program name listening on the port.

To print numeric values rather than service names, add the -n flag.

4. Using lsof Command

The final tool we will cover for querying open ports is lsof command, which is used to list open files in Linux. Since everything is a file in Unix/Linux, an open file may be a stream or a network file.

To list all Internet and network files, use the -i option. Note that this command shows a mix of service names and numeric ports.

$ sudo lsof -i

The outcome of the command is added below.

dbus-daem 748 messagebus 8u IPv4 20706 0t0 TCP 192.168.1.27:57600->192.168.1.252:ldap (ESTABLISHED)

NetworkMa 792 root 17u IPv4 25402 0t0 TCP 192.168.1.27:57634->192.168.1.252:ldap (ESTABLISHED)

accounts- 795 root 10u IPv4 19123 0t0 TCP 192.168.1.27:57604->192.168.1.252:ldap (ESTABLISHED)

cups-brow 803 root 8u IPv4 18158 0t0 UDP *:ipp

polkitd 884 root 11u IPv4 26090 0t0 TCP 192.168.1.27:57632->192.168.1.252:ldap (ESTABLISHED)

lightdm 1038 root 15u IPv4 25858 0t0 TCP 192.168.1.27:57622->192.168.1.252:ldap (ESTABLISHED)

nscd 1047 root 18u IPv4 23726 0t0 TCP 192.168.1.27:57606->192.168.1.252:ldap (ESTABLISHED)

lightdm 1377 root 3u IPv4 24167 0t0 TCP 192.168.1.27:57618->192.168.1.252:ldap (ESTABLISHED)

(sd-pam 1387 jackson 7u IPv4 24206 0t0 TCP 192.168.1.27:57624->192.168.1.252:ldap (ESTABLISHED)

openvpn 2045 root 3u IPv4 29857 0t0 UDP *:42720

firefox 2836 jackson 46u IPv4 304017 0t0 TCP 192.168.1.27:56490->172.217.194.189:https (ESTABLISHED)

firefox 2836 jackson 59u IPv4 362263 0t0 TCP 192.168.1.27:47012->192.168.1.253:http (ESTABLISHED)

To find which application is listening on a particular port, run lsof in this form.

$ sudo lsof -i :80

To list all Internet and network files, use the -i option.

-i ignore the case of letters

-c disables the reporting of any path name components from the kernel’s name cache.

-p For selecting process ID

Conclusion

Paying attention to which ports are listening on your network is important as open ports can be evidence of an intrusion on your network. Knowledge of the Linux open ports and the kind of information being sent out helps you to check malicious efforts aimed at your system. Knowing this is an important part of securing your system.

 

security audit

  • Linux

Looking for AWS Experts?

We provide top-of-the-line custom AWS setup services tailored to your needs.

Applying Kernel Patch Without Rebooting

Applying Kernel Patch Without Rebooting
  • Server Monitoring
logo

Best practices to reduce customer complaints in shared hosting support

Best practices to reduce customer complaints in shared hosting support
  • Customer Care
logo

Monitor changes made to a file using auditd

Monitor changes made to a file using auditd
  • Security
  • Server Monitoring
logo

Why should you think of outsourcing backup management?

Why should you think of outsourcing backup management?
  • Backup management
logo
To check which all ports are listening (Introducing Four Linux Commands)

Posts by Ruben Roy

Ruben Roy