1 min read

Open connections to a server using netstat and watch

Etienne Marais

Sometimes you want to see how many open or active connections are currently running on a server.

netstat

netstat -an | grep ESTABLISHED | wc -l

# Outputs
7

watch

If you want to have a watcher setup that refreshes every second, run the following in a terminal window:

watch -n1 -d "netstat -an | grep ESTABLISHED | wc -l"

# Outputs
Every 1.0s: netstat -an | grep ESTABLISHED | wc -l  Wed Jan  3 13:28:28 2018
7