Updated: 22 October 2026 · Applies to: any Linux distribution, net-tools or iproute2

Every network service on Linux listens on a protocol (usually TCP or UDP) and a port number. Here is how to list and watch which ports are open in real time.

List all open ports

netstat is deprecated on most current distributions in favor of ss, which shows more detailed network statistics, but both still work where installed:

sudo netstat -tulpn

or:

sudo ss -tulpn

The flags:

  • -t: list TCP ports.
  • -u: list UDP ports.
  • -l: show only listening sockets.
  • -n: show numeric port numbers instead of service names.
  • -p: show the process or program name using each port.

Watch ports in real time

Combine either tool with watch to refresh the listing automatically:

sudo watch netstat -tulpn

or:

sudo watch ss -tulpn

Either command refreshes the listing every couple of seconds by default; press Ctrl+C to stop watching. This is useful for confirming a service actually starts listening after you restart it, or for spotting an unexpected process holding a port open.

Running netstat or ss with sudo matters here: without root privileges, the -p flag cannot show which process owns a socket belonging to another user, so the process column comes back empty for anything you do not own on the server.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket