Linux – netstat command .

This tutorial come to show you how to use the netstat command with linux operating system.
To list out all the connections tcp, udp & unix on a system, we can use ‘a’ option with netstat command:

To list only the tcp connections our system, use ‘t’ options with netstat:

To list out only the udp connections on our system, we can use ‘u’ option with netstat:

To only list out Unix socket connections, we can use ‘x’ options:

To get list of all connections along with PID or process name, we can use ‘p’ option & it can be used in combination with any other netstat option:

To speed up our output, we can use ‘n’ option as it will perform any reverse lookup & produce output with only numbers (since no lookup is performed, our output will much faster):

To print only the listening ports , we will use ‘l’ option with netstat (it will not be used with ‘a’ as it prints all ports):

To print network statistics of each protocol like packet received or transmitted, we can use ‘s’ options with netstat:

To display only the statistics on network interfaces, use ‘i’ option:

To display multicast group information, we can use option ‘g’ ( that print the multicast group information for IPV4 & IPV6):

To print the network routing information, use ‘r’ option:

To get continuous output of netstat, use ‘c’ option:

To filter a single port connections, we can combine ‘grep’ command with netstat:

To use multiple commands with netstat.
Example: count the number of connections with CONNECTED value, we can further add ‘wc’ command with netstat and grep command:


born 1976
Posted in All, Commands, Linux. Tagged with , , , , .