How to Install netstat Command in Linux

Netstat – derived from the words network and statistics – is a command-line utility used by system administrators for analyzing network statistics. It displays a whole manner of statistics such as open ports and corresponding addresses on the host system, routing table, and masquerade connections.

In this article, we will walk you through how you can install the netstat command in different Linux distributions.

How to Install netstat Command in Linux

The package that contains netstat is called net-tools. On modern systems, the netstat utility comes pre-installed and there’s no need to install it.

On older systems, however, you are likely to bump into an error when you run the netstat command. Therefore, to install netstat on Linux distributions, 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 net-tools      [On Arch Linux]

Once installed, run the command below to check the version of netstat installed.

# netstat -v

How to Use netstat Command in Linux

You can invoke the netstat command on any of the Linux distributions to get different statistics on your network.

1. Viewing the Network Routing Table

You use the -r flag to show the network routing table to get something similar to the output below.

# netstat -nr
List Network Routing Table
List Network Routing Table

The -n option forces netstat to print addresses separated by dots instead of using symbolic network names. The option is useful for avoiding address lookups over a network.

2. Display Network Interface Statistics

Use the -i flag to get an output of statistics of a network interface that is configured. The -a option prints all present interfaces in the kernel.

# netstat -ai
List Network Interface Statistics
List Network Interface Statistics

3. Show Network Connections

The netstat command utility supports options that display active or passive sockets using the options -t, -n, and -a. The flags show RAW, UDP, TCP, or UNIX connection sockets. Adding the -a option, it will sow sockets ready for connection.

# netstat -ant
List Network Connections
List Network Connections

4. Show Network Services

To list services, their current state, and their corresponding ports, run the command.

# netstat -pnltu
List Network Services
List Network Services

In this article, we shed light on how you can install netstat command and how it is used to checking a wide array of network statistics. It’s also important to point out that netstat has been deprecated and instead ss utility has taken its place in displaying more refined network statistics.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

3 thoughts on “How to Install netstat Command in Linux”

  1. I should point out that it is actually the most modern system that is likely to be missing netstat since ss is a newer replacement.

    Reply
  2. Arch Linux install is incorrect. “netstat-nat” is a different package that does not install the same.

    It should be:

    pacman -S net-tools
    
    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.