Connections

Debian/Ubuntu

Show open socket connections

sudo netstat -tulpan

macOS Sierra

Show open TCP socket connections

sudo lsof -nP -i4TCP

Show open TCP socket connections, filter for port 8080 and status LISTEN

lsof -nP -i4TCP:8080 | grep LISTEN

Firewall

Show ufw firewall status

sudo ufw status