How to use Netstat command in linux

Netstat command is used to displays various network related information such as network connections, routing tables, masquerade connections, multicast memberships. This article targets the audience which has Linux Based VPS or Linux Based Dedicated Server.

1. To list all ports listening and non-listening we use the commands:

$ netstat –a | more

 netstat

2. To list all tcp ports we use below command:

$ netstat –at | more 

netstat

3.To list all udp ports we use below command:

$ netstat –au | more

netstat 

4. To list sockets which are in listen to state we use commands:

$ netstat –l | more

 netstat

$ netstat –lt | more  :: listing all tcp ports

 netstat

$ netstat –lu | more :: listing all udp ports

 netstat    

5. To show the statistics for each protocol we use below commands:

$ netstat –s

 netstat

$ netstat –st  :: listing all tcp ports

 netstat

$ netstat –su  :: listing all udp ports

  netstat       

6. To display PID and program names in netstat output we use below commands:

$ netstat –lp

$ netstat –tp  ::listing all tcp ports

$ netstat – lup  ::listing all udp ports

7. To print netstat information continuously we use commands:

$ netstat –c  

netstat 

$ netstat –tc  :: listing all tcp ports

$ netstat –sc  :: listing all udp ports

8. To find the non-supportive address families in your system we use below command:

$ netstat –verbose

 netstat

9. To display the kernel routing information we use below command:

$ netstat –r

 netstat

10. To find out on which port a program is running we use below commands:

$ netstat –ap | grep ssh

$ netstat –an | grep 80

11. To show the list of network interfaces we use commands:

$ netstat –i

 netstat

$ netstat –ie

 netstat

12. To show the list of all UNIX listening ports we use below command:

$ netstat –lx

netstat 

13. To show the list of promiscuous Mode we use below command:

$ netstat –ac 5 | grep tcp

 netstat

14. To show the list of IPV4 and IPV6 we use commands:

$ netstat –g

 netstat

15. To show the list Raw Network Statistics we use commands:

$ netstat  --statistics –raw

 netstat

 

NOTE: Please remember that we do not support Linux command line via phone or live chat. You can ask for shell help via email to support@websouls.com or use one of the numerous websites which offer to teach shell.

We hope that the above article was beneficial to you if you liked it please give us a thumbs up.

Technical Support,

WebSouls.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Shell Commands

Please remember that we do not support Linux command line via phone nor live chat. You can ask...