How to Install netstat on Ubuntu Linux



The article discusses how to install netstat, a network monitoring tool, on Ubuntu Linux, which is not automatically installed. Confusion with direct netstat installation is rectified by installing the ‘net-tools’ package instead using ‘sudo apt install net-tools’ command via Terminal. The installation can be verified by checking the version through ‘netstat –version’ command.

This article explains installing netstat, a command line utility for troubleshooting network activity on Ubuntu Linux.

Netstat is a command-line utility for troubleshooting and monitoring network activity on Linux systems, including Ubuntu. It displays network connections, routing tables, and network interface statistics.

However, the netstat package is not installed on Ubuntu Linux automatically. When you run the netstat command Ubuntu, you may get an error message that reads “Command ‘netstat’ not found.”

Using the apt install netstat also won’t install the package on Ubuntu Linux. That’s because the netstat package is included in Ubuntu’s repositories via the net-tools packages.

You need to install the net-tools package to get netstat installed on Ubuntu Linux. In other words, replace “sudo apt install netstat” with “sudo apt install net-tools” to install the netstat command in Ubuntu Linux.

Step 1: Open the Terminal

To install netstat, we need to access the Terminal. You can do this by pressing the Ctrl+Alt+T key combination or by searching for “Terminal” in the Applications menu.

Step 2: Update the package list

Before installing any new packages, updating the package list on your Ubuntu system is recommended. This ensures that you have the latest repositories and package information.

In the Terminal, execute the following command:

sudo apt update

Enter your password when prompted, and press Enter to proceed. This command will update the package list.

Step 3: Install the netstat package

Once the package list is updated, you can install the netstat package.

In the Terminal, enter the following command:

sudo apt install net-tools

This command will install the net-tools package, which includes netstat, onto your Ubuntu system.

Confirm the installation by typing Y and pressing Enter.

Step 4: Verify the Installation

To verify that netstat is installed correctly, you can run the following command:

netstat --version

If netstat is installed properly, you should see the version information in the Terminal.

Feel free to explore the options and parameters available with netstat by utilizing the man command in the Terminal.

For example:

man netstat

This command will display the manual page for netstat, providing detailed information on how to use the utility.

Some useful netstat commands are below.

Find all listening ports

netstat -l

List listening TCP ports

netstat -lt

List listening UDP ports

netstat -lu

Monitor the network and get network statistics

netstat -c
netstat -s

That should do it!


This post showed you how to install the netstat command on Ubuntu Linux. Please use the comments form below if you find errors or have something to add.

Like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.