Check Open Ports on Your System
Linux: Using ss
The ss command is the modern replacement for netstat and is available on all current Linux distributions:
sudo ss -tulnp
Here's what each flag does:
-t— Show TCP sockets-u— Show UDP sockets-l— Show only listening (open) sockets-n— Show numeric ports instead of service names-p— Show the process using each socket
The output shows the local address and port, the process name, and its PID. This is the fastest way to see what's listening on your system.
Linux: Using netstat (legacy)
The netstat command provides the same information but is being phased out in favor of ss:
sudo netstat -tulnp
The flags are identical to ss. On newer Ubuntu/Debian systems, you may need to install it first:
sudo apt install net-tools
Use ss when possible—it's faster and doesn't require an extra package.
Windows: Using netstat
Open PowerShell (or Command Prompt) and run:
netstat -ano | findstr LISTENING
This lists all listening ports. The last column is the PID (Process ID). To find out which program owns a specific PID:
Get-Process -Id 1234
Replace 1234 with the actual PID from the netstat output. The ProcessName column tells you which application is listening on that port.
Scan from outside (optional)
The commands above show what your system thinks is open. To verify from a network perspective, use nmap:
nmap -sT localhost
This performs a TCP connect scan on your own machine. To scan a remote host:
nmap -sT target_ip
Important: Only scan systems you own or have explicit permission to scan. Unauthorized port scanning can violate terms of service and may be illegal in some jurisdictions.
Master network scanning with our complete Nmap tutorial.