Posts

Showing posts from August, 2020

Find the process listening on a port

Using netstat PORT=80; sudo netstat -ltnp | grep ":${PORT}" Using lsof PORT=80; sudo lsof -i :${PORT}

Show connections per destination for a specific port

PORT=5432; netstat -an |grep ":${PORT} " | \ awk '{count[$5]++} END {for (host in count) print host, count[host]}' To view the same over time: PORT=5432; watch "netstat -an |grep \":${PORT} \" | \ awk '{count[\$5]++} END {for (host in count) print host, count[host]}'"