Netstat is a command-line tool available in Linux that allows you to display various network-related information, such as active network connections, routing tables, and network interface statistics. It can be used to troubleshoot network issues, monitor network activities, and gather information about network connections.
Here’s how to use
netstat on Linux:
- Open a Terminal: To use
netstat, you need to open a terminal on your Linux system. You can usually find the terminal application in the Applications or System Tools menu, or you can use the keyboard shortcut
Ctrl + Alt + T.
- Basic Usage: The basic syntax of the
netstatcommand is as follows:
- Display All Active Connections: To display a list of all active network connections, including TCP, UDP, and UNIX domain sockets, run the following command:
- Display Listening Ports: To view all listening ports on your system, use the following command:
- Display Network Statistics: To show statistics for each protocol (TCP, UDP, and ICMP), run:
- Display Network Routing Table: To view the kernel’s IP routing table, use the following command:
- Display PID and Program Name: To see which processes (identified by their PIDs) are using the network connections, add the
- Continuous Monitoring: If you want
netstatto continuously update and display network activities, use the
netstat is a powerful command with various options. For more detailed information and additional options, you can refer to the
netstat man page by typing
man netstat in the terminal.
Keep in mind that
netstat is being phased out in favor of other commands like
ss (Socket Statistics) and
ip (IP tool). These newer tools provide more comprehensive and detailed information about network connections. However, for compatibility reasons,
netstat is still available on most Linux distributions.