What is netstat command and what does it means?
The full meaning of netstat is Network statistics, This is a functionality that enables you to monitor or handle your network. All operating system uses netstat and it is good for network troubleshooting.
However, there is an update in netstat command, it is now ss command. Which is stronger and more efficient than netstat. That by the way!. netstat gives an overview of network information and as well displays port that are available or the ones that are connected.
You can use following commands as replacement of netstat command if you are working in newer version:
ss, ip route (for netstat-r), ip -s link (for netstat -i), ip maddr (for netstat-g)
10 ways to use netstat command in Linux
First of all,to get started with netstat you need to have it installed on your command line. Now let us check the 10 examples and usages of netstat command. Let's go
1. netstat -a
$ netstat -a or netstat -all
More often than not, its also used with other options like netstat -nap or netstat -nao where a is for all and n is for numeric
2. netstat -r example to display the routing table
Why do I need to display the routing table? First of all, a routing table is a manual, or let me say it contains a set of rules which is viewed in a table format, this tells us or is used to determine where data sent over the internet are directed. I hope this explains why you need to display the routing table. There could be times or instances that you may have to do that.
$ netstat -r
Here is the output of the command, you can see the routing table below:
3. netstat -au command to display the UDP information
And you do that with two different options the -au and -a
--udp.
$ "netstat -au" or "netstat -a --udp"
What is UDP? UDP stands for user datagram protocol. It is such a protocol for communicating throughout the internet. You use this command when you need information about the communication going through the internet.
4. Use netstat -l to display all server connections
$ "netstat -l"
By using the command above with the option -l this lists out all the listening connections. Displays protocol statistics and current TCP/IP network connections. What does that mean? A listening connection is a state, it only means that a service is listening for or to connections on that port.
5. netstat -s to display the network statistics simply do the below
$ netstat -s
The command above would print the summary statistics for each protocol such
as TCP, UDP, etc. There could be times you may need to see the network statistics--
6. netstat -tcp to get the TCP port information
$ "netstat --tcp"
There could be times you may want to see the TCP port information
7. netstat - i to Show network interface connection
$ netstat -i
This shows the network interface packet transactions both at the transferring and the receiving packets with the MTU size as well, You may be wondering what an MTU means, it stands for maximum transmission units.
8. netstat -n to show the network addresses as numbers
$ netstat -n
The command shows the addresses of the networks as numbers. netstat would
only display addresses as symbols by default but the option -n enables us to
display it in any format. Showing network addresses as numbers is more readable than
symbols.
9. netstat -p to show the name of the program
$ netstat -p
The command shows or tells us the name of the program a socket or network belongs to. This is very useful because there could be times when you may want to see the program associated with ports and their addresses.
Though, if you want IP address of foreign host then you can also combine -p with -n and run a command like netstat -nap
10. netstat -c to continuously print netstat information
$ netstat -c
This above command will print netstat information continuously
11. netstat -g to display multicast group
$ netstat - g
That's all about different ways to use netstat command in Linux. In this article, you learned what netstat means which is used for analyzing network statistics. The 10 different examples were provided which are, to display all information, display the routing table, display the UDP information, display the listening connection, show the network statistics, get the TCP port information, show network addresses as numbers, show the name of the program and to continuously print netstat information.
Other Linux Articles and Resources you may like
- 5 Example of kill commands in Unix and Linux (example)
- 10 examples of Networking commands in Unix (nslookup)
- How to set up cron jobs in Linux (Crontab example)
- Top 5 Courses to learn Vim Editor (online courses)
- 10 Examples of chmod command in Linux (chmod)
- VI Editor examples and tips for beginners (vi examples)
- 10 Linux command line courses for Beginners (courses)
- How does the nslookup command work in UNIX? (answer)
- 10 examples of lsof command in Linux? (examples)
- 7 Best Linux Courses for DevOps Engineers (Linux courses)
- How to use the netstat command to find which process is listening on a port? (example)
- Linux find + du + grep example (example)
- 10 Examples of curl command in Linux (cURL)
Thanks for reading this article so far. If you like these Linux tutorial about using lsof command and my examples then please share it with your friends and colleagues.
No comments:
Post a Comment
Feel free to comment, ask questions if you have any doubt.