netstat code example

Example 1: netstat install

# apt install net-tools     [On Debian/Ubuntu]

Example 2: netstat command in linux

# netstat -at

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 localhost:ipp               *:*                         LISTEN
tcp        0      0 localhost:smtp              *:*                         LISTEN
tcp        0     52 192.168.0.2:ssh             192.168.0.1:egs             ESTABLISHED
tcp        1      0 192.168.0.2:59292           www.gov.com:http            CLOSE_WAIT

Example 3: netstat pid

sudo netstat -plnt

Example 4: netstat syntax

netstat [-OPTION1] [-OPTION2] [-OPTION3] …mixed