How To: Linux Netstat Command Line For Checking Connection

Netstat (Network Statistic) is command line utility which used for monitoring both incoming and outgoing network connections, routing tables, interface statistic etc. Netstat can be used to print all the connected TCP and UDP socket connections and listening socket too while waiting for incoming connections.

Netstat available on MAC, Linux and Windows etc. But i using Slackware Linux for day activies, like my post previously about “Monitoring tools on Linux for Security”. Yeah this tools can be used for system administrator for monitoring traffice network performance and troubleshoot related-network problems.

This tutorial for using linux netstat command line, so familiarize command line interface. LOL

List All TCP and UDP Connections
This netcat command for show list all TCP and UDP connections, simply run netstat command with “-a” option.

list all tcp and udp connections

On screenshot output command with netstat -a was give message show all the established and listening TCP and UDP socket connections.

List Only TCP Connection
For list only TCP connection, simply run command netstat with -at option. Option “t” is for show all list TCP connection not UDP connection.

show all list only tcp connection, netstat, linux-command 
 Output netstat -at (image:

List Only UDP Connection
Netstat command can use for list only UDP connection, so simply run command netstat with “-au” options. Option “u” is for show all list UDP,

linux-command, list all only UDP connection, netstat

On screenshot output was give message show all list only UDP connection using netstat.

List All Listening Connection
This netstat command for show all list listening connection, simply run netstat command with “-l” option.

On screenshot give output to show all list connection both TCP and UDP.

Disable Reverse DNS Lookup For Faster Output
By default, the netstat command tries to find the hostname of each IP address in the connection by doing a reverse DNS lookup. This slows down the output. Simply run netstat command using “-n” option for disable reverse DNS lookup.

linux-command,, disable reverse dns lookup for faster output, netstat

List The Process Name And User ID
When viewing the open listening ports and connections, it’s necessary to know the process name which has opened that port or connection. Simply run netstat command using “-nlpt” option.

linux-command, netstat, list the process name which opened port,

For get username along with process, simply run netstat command using “e” option., linux-command, netstat, get username along with process

List Network Statistic
The netstat command can also be used to print network statistics of the total number of packets received and transmitted by protocol type. Simply run “netstat -s” for list network statistic.

list network statistic with netstat -s,, netstat, linux-command

Displaying Ipv4 and Ipv6 Information
Displaying Ipv4 and Ipv6 information with netstat command, simply run “netstat -g” for show information both Ipv4 and Ipv6., netstat, linux-command, show Ipv4 and Ipv6 information

Display Network Interfaces Statistic
Netstat command also can show interface statistic, as system administrator will surely require. Simply for show network interface statistic using netstat command type command “netstat -ie”.

linux-command, netstat,, display network interface statistic netstat

This post just share to learn using netstat command line in linux, so it’s just learning network use linux. This netstat command for information for use as SysAdmin and not for hacked tutorial. If less clear can ask to me with follow google+ account or my official twitter or also read netsta manual.

This post is licensed under CC BY 4.0 by the author.