How to Check Open Ports on Ubuntu

Published April 17, 2025
What Is Unraid and How to Install It on an Ubuntu Server
Cheap Dedicated Server

How to Check Open Ports on Ubuntu


Checking open ports on your Ubuntu system is essential for security and troubleshooting. Whether you’re running a server or debugging a connection issue, knowing which ports are open and which service is using them can help.

Here are several easy ways to check open ports in Ubuntu.


1. Using ss (Socket Statistics)

The ss command is a modern alternative to netstat and is pre-installed on most Ubuntu systems:
Using ss

ss -tuln
  • -t: Show TCP connections
  • -u: Show UDP connections
  • -l: Display listening sockets
  • -n: Show numerical port numbers instead of resolving service names

To get more detailed info (like the process using the port):
To get more detailed info

sudo ss -tulnp

2. Using netstat (if installed)

If you’re using an older system or prefer netstat, install it via:
Using netstat

sudo apt install net-tools

Then run:

netstat -tuln

Or for process info:

sudo netstat -tulnp

3. Using lsof (List Open Files)

lsof can show which process is using a port:
Using lsof

sudo lsof -i -P -n

To check a specific port (e.g., 80):

sudo lsof -i :80

4. Using nmap for Port Scanning

Install nmap:

sudo apt install nmap

Scan localhost:
Using nmap for Port Scanning

nmap -sT localhost

 

How to Check Open Ports on Ubuntu (F.A.Q)

How can I check if a specific port is open?

Use ss -tuln | grep :PORT, replacing PORT with the desired number.

What is the easiest way to list all listening ports?

Use ss -tuln or sudo lsof -i -P -n.

How do I find which service is using a port?

Run sudo lsof -i :PORT or sudo ss -tulnp | grep :PORT.

Is it safe to expose open ports?

Only if secured and required. Exposing unused or unsecured ports can be a security risk.