netstat Cheatsheet - Linux Network Troubleshooting Reference
Two things dominate day-to-day netstat: is anything listening on my port, and how many ESTABLISHED versus TIME_WAIT connections do I have. Combine -a with -p and you get both the listener and the process holding the port; this table covers those checks plus routing and interface stats, so a quick "is it open / is it healthy" triage needs no extra tooling.
View Connections 6
netstatShow all active connections
netstat -aShow all listening and non-listening ports
netstat -atShow TCP connections only
netstat -auShow UDP connections only
netstat -anDon't resolve names/ports (faster)
netstat -anpShow PID and process name (needs root)
Listening Ports 6
netstat -lShow all listening ports
netstat -ltShow TCP listening ports
netstat -luShow UDP listening ports
netstat -lxShow Unix socket listeners
netstat -lntpTCP listeners with processes (root); most common
netstat -lnupUDP listeners with processes
Routing Table & Interface Stats 5
netstat -rShow the routing table (like route)
netstat -rnRouting table without hostname resolution (faster)
netstat -iShow interface statistics (packets in/out)
netstat -ieInterface details (like ifconfig)
netstat -rn | grep UGShow only the default gateway route
Protocol Statistics 5
netstat -sShow statistics for all protocols
netstat -stShow TCP statistics
netstat -suShow UDP statistics
netstat -s | grep -i errorShow network error statistics
netstat -s | grep -i retransShow TCP retransmission statistics
Filter by State & Troubleshoot 6
netstat -an | grep ESTABLISHEDShow established connections
netstat -an | grep TIME_WAITShow TIME_WAIT connections
netstat -an | grep :80Show connections on port 80
netstat -lntp | grep :80Find which process listens on port 80
netstat -an | awk '{print $6}' | sort | uniq -cCount connections per state
netstat -an | grep ESTABLISHED | wc -lCount current active connections
Advanced Options 6
-nNo name resolution; shown faster
-pShow PID and name of the owning process (root)
-c 1Continuously output every second (live monitoring)
-oShow connection timer information
-eShow extra info: user and inode columns
-vVerbose: show unconfigured interfaces
Alternatives (ss / ip) 5
ss -tlnpss replaces netstat -tlnp; faster
ss -tn state establishedFilter established connections with ss
ss -sConnection statistics summary with ss
ip addrip replaces ifconfig/netstat -ie for interfaces
ip routeip replaces netstat -r for the routing table
Tips
- netstat is being replaced by ss; on newer systems prefer ss (faster, modern).
- Viewing processes needs root, otherwise the PID column shows -.
- Too many TIME_WAIT means frequent short connections; consider long-lived connections or a pool.
- netstat -an is fastest; -p slows it down by mapping processes.
- ss reads kernel data via netlink, an order of magnitude faster than netstat.
- The most common port-occupancy check is netstat -tlnp | grep <port>.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us