Linux Command "NETSTAT"

Netstat Commands

The netstat is a Terminal command which shows details regarding how our computer system is communicating with other network components.

Basically, the netstat command displays detailed statistics of every individual network connection, 
network interfaces, routing tables, network protocols, and other network-specific information. 
netstat helps us to deal with network issues and encourages network admins to have better performance measurements.

Prerequisites

  • Access to the terminal
  • Installed net-tools software package

Netstat Commands

1. Enlisting all ports (Listening ports and Non-listening ports)

netstat -a

netstat -a

To enlist all TCP ports, enter:
netstat -at

netstat -at

To enlist all UDP ports, enter:
netstat -au

netstat -au

2. Enlisting all Listening ports

To enlist all ports in the Listening state:
netstat -l

netstat -l

To enlist all TCP ports in Listening state:
netstat -lt

netstat -lt

To enlist all UDP ports in Listening state:
netstat -lu

netstat -lu

To enlist all UNIX ports in Listening state:
netstat -lx

netstat -lx

3. Display Statistics of Protocol

To show statistics of all protocols:
netstat -s

netstat -s

To show statistics of TCP protocol:
netstat -nt

netstat -nt

To show statistics of UDP protocol:
netstat -su

netstat -su

4. Display Process ID/Program ID (PID) and Program Name

netstat -pt

netstat -pt

This command will display all the processes/programs running on corresponding ports.

5. Display netstat Continuously

netstat -c

netstat -c

6. To show non-supportive Address families

netstat --verbose
After running the above command, you will observe some lines at the end which read as:

netstat --verbose

7. Show Kernel IP Routing Table

netstat -r

netstat -r

8. Enlist all Network Interfaces

netstat -i

netstat -i

To display detailed information about each network interface, run the following command:
netstat -ie

netstat -ie

Conclusion

Netstat is an essential tool for network engineers, system administrators, and developers. 
Troubleshooting network problems and having an overview of all the network activities and port availability are just some use cases of this tool.

Post a Comment

© LinuxFault. All rights reserved. Developed by Jago Desain