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.
netstat -a
- Display only TCP connections.
netstat -at
- Display only UDP connections.
netstat -au
- Display network statistics for each protocol.
netstat -s
- Display routing table information.
netstat -r
- 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.
netstat -l
- To list only the listening tcp ports.
netstat -lt
- To list only the listening udp ports.
netstat -lu
- List only the listening UNIX ports.
netstat -lx
- List the statistics for TCP (or) UDP ports.
netstat -st
netstat -su (UDP) List the statistics for UDP ports.
- To get the list of network interfaces.
netstat -i
- Displays all TCP connections.
netstat -t
- Displays addresses and port numbers in numerical format instead of resolving them to hostnames and service names.
netstat -n
- To get the port on which a program is running.
netstat -ap
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
Also Read:
What are TCP and UDP ports? How do they work?