Displays various networks related information such as open connections, open socket ports etc.

# To view which users/processes are listening to which ports:
sudo netstat -lnptu

# To view routing table (use -n flag to disable DNS lookups):
netstat -r

# Which process is listening to port <port>
netstat -pln | grep <port> | awk '{print $NF}'
# Example output: 1507/python

# Fast display of ipv4 tcp listening programs
sudo netstat -vtlnp --listening -4

# To list all ports
netstat -a

# To list all listening ports
netstat -l

# To display PID and program names
netstat -p

# To find out which port a process is running (e.g. find out which port ssh is listening on)
netstat -ap | grep ssh

# To find out which process is listening on a particular port
netstat -ap | grep ':80'

# To list all Active Connections (TCP and UDP)
netstat -a -b