How to install netstat command in Linux

User 4988085 2022-06-24 06:13:46 阅读数:161


Netstat ( From the web and Statistics ) Is a command line utility used by system administrators to analyze network statistics . It shows the complete statistics , For example, open ports and corresponding addresses on the host system , Routing table and masquerade connection .

In this paper , We will guide you step-by-step through how to Linux Install... In the distribution netstat command .

How to be in Linux Install in netstat command

contain netstat The software package for is called net-tools . On modern systems , netstat Utility pre installed , So there is no need to install .

however , On older systems , function netstat The command may encounter errors . therefore , To be in Linux Install... On the distribution netstat , Please run the command .

# yum install net-tools [On CentOS/RHEL]
# apt install net-tools [On Debian/Ubuntu]
# zypper install net-tools [On OpenSuse]
# pacman -S netstat-nat [On Arch Linux]

After installation , Run the following command to check the installed netstat edition .

# netstat -v

How to be in Linux Use in netstat command

You can do it any time Linux Call... On the distribution netstat Command to get different statistics on the network .

1. View the network routing table

You can use -r Flag to display the network routing table , To get something similar to the following output .

# netstat -nr

List the network routing table

-n Option enforcement netstat Print addresses separated by dots , Instead of using symbolic network names . This option is useful to avoid finding addresses over the network .

2. Display advertising network interface statistics

Use -i Flag to obtain the output of configured network interface statistics . -a Option to display all current interfaces in the kernel .

# netstat -ai

List network interface statistics

3. Show network connections

netstat The command utility supports the use of options -t , -n and -a To display options for active or passive sockets . These signs show RAW,UDP,TCP or UNIX Connect socket . add to -a Options , It will seed the socket to connect .

# netstat -ant

List network connections

4. Show network services

To list services , Their current status and corresponding ports , Please run the command .

# netstat -pnltu

List network services

In this paper , We explained how to install netstat Command and how to use it to check various network statistics . It is also important to point out that netstat Has been abandoned , and ss The utility replaces it to display more detailed network statistics .

copyright:author[User 4988085],Please bring the original link to reprint, thank you.