Cybersecurity Triage
Read-onlyList Listening Ports on a VPS
You need a snapshot of TCP ports listening on the server.
Command
ss -ltnp
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not treat a listener as externally reachable without checking firewall and bind address.
Expected output
Listening sockets with local addresses, ports, and process names where available.
System impact
Read-only. Nothing changes. The command lists listening TCP sockets and processes.
Recovery / rollback: no state is changed.
When to use it
Use during exposure checks, incident triage, or after deploying services.
When not to use it
Do not treat a listener as externally reachable without checking firewall and bind address.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ ss -ltnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=801,fd=3))
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1907,fd=6))
LISTEN 0 511 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=1907,fd=7))
LISTEN 0 128 localhost:5432 0.0.0.0:* users:(("postgres",pid=2011,fd=7))
$ ss -ltnp | awk 'NR==1 || /LISTEN/'
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=801,fd=3))
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1907,fd=6))
LISTEN 0 511 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=1907,fd=7))
LISTEN 0 128 localhost:5432 0.0.0.0:* users:(("postgres",pid=2011,fd=7))
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
ss -ltnpss -ltnp | awk 'NR==1 || /LISTEN/'
next steps
Related commands
Find Listening Ports with ss
Before blaming the firewall, check whether anything is actually listening.
ss -ltnp
List Listening TCP Sockets
Firewall rules matter after you know what is listening.
ss -ltnp
Find Public Listeners Not Allowed by UFW
The process was public, but the firewall did not mention it.
comm -13 <(ufw status numbered | awk '/ALLOW/ {print}' | grep -Eo '[0-9]+/(tcp|udp)' | cut -d/ -f1 | sort -u) <(ss -ltnp | awk '$4 ~ /^(0[.]0[.]0[.]0|[[]::[]]|[*]):/ {n=split($4,a,":"); print a[n]}' | sort -u)
Show Publicly Bound Listeners
Localhost services are different from public listeners.
ss -ltnp | awk 'NR==1 || $4 ~ /^(0[.]0[.]0[.]0|[[]::[]]|[*]):/'
Find Allowed Ports with No Listener
An open firewall rule can outlive the service it was created for.
comm -23 <(ufw status numbered | awk '/ALLOW/ {print}' | grep -Eo '[0-9]+/(tcp|udp)' | cut -d/ -f1 | sort -u) <(ss -ltnp | awk '/LISTEN/ {n=split($4,a,":"); print a[n]}' | sort -u)
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.