The netstat command in Linux is used to monitor network connections and display statistics about them. It is a powerful tool for network troubleshooting and monitoring. It can be used to view incoming and outgoing traffic, as well as active TCP/IP connections.
Netstat also provides useful information such as the source and destination IP addresses, port numbers, packet size, etc. Additionally, it can be used to troubleshoot network-related problems such as slow response times or dropped packets. With this command, users can quickly identify potential issues with their network setup and take corrective action.
Here are some common uses of the netstat command
- Display all active network connections.
- Display only TCP connections.
- Display only UDP connections.
- Display network statistics for each protocol.
- Display routing table information.
- Display the PID (process identifier) and name of the program that is using a specific port.
netstat -p | grep <port number>
- Display the IP addresses and port numbers that are being listened on.
- To list only the listening tcp ports.
- To list only the listening udp ports.
- List only the listening UNIX ports.
- List the statistics for TCP (or) UDP ports.
netstat -su (UDP) List the statistics for UDP ports.
- To get the list of network interfaces.
- Displays all TCP connections.
- Displays addresses and port numbers in numerical format instead of resolving them to hostnames and service names.
- To get the port on which a program is running.
Note that some options may require superuser privileges to execute. You can find more information about the
netstat command by typing
man netstat in the terminal.
Download: netstat command in linux pdf
What are TCP and UDP ports? How do they work?
10 Best Troubleshooting Commands to Use in Linux