Bash: netstat: command not found - Debian/Ubuntu Linux - LinuxConfig.org

If you are looking for the netstat command and getting error:
bash: netstat: command not found

This is a companion discussion topic for the original entry at https://linuxconfig.org/bash-netstat-command-not-found-debian-ubuntu-linux

Kuba Nowacki

THANKS!

Augusto Santos

Thanks !!!

Gabriel RB

Thank you.

6/11/2019

This did not work on ubuntu 18 bionic beaver

i am getting a message saying net-tools is fully up to date with zero ability to run

apt install netstat

or any other variant

sudo apt-get etc.

package is not found

Hi Johnathon,

Welcome to our forums.

Utilities or commands VS the packages they are contained in can be indeed confusing at first. netstat is the command you’d like to use, and net-tools is the package that contains it. By installing the package, you gain access to the command. If your query says that the package is installed, you already have the netstat command. You can test it with something like:

$ netstat --version

There is no individual package called ‘netstat’, that’s why you get an error with apt.

Sandmann

1 Like

@sandmann,

I run into the same problem as Johnathon. Using

#netstat --version.
I confirm netstat doesn’t exist.
Then do

apt install net-tools

Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package net-tools

My OS is ubuntu 18.04

Hi Remoteblue,

Welcome to our forums.

It is strange that your system can’t locate the package, I have just tested it on an Ubuntu 18.04.3 machine, and it does see the package with the default repository configuration.

Do you have the main repository enabled?

You can find that by executing:

$ cat /etc/apt/sources.list | grep main | grep -v "#"

If you get lines from the above, please post them here.

It should be something like the following:

deb http://<ubuntu-repository-next-to-you>/ubuntu/ bionic main restricted

You may also want to try updating the apt cache by executing:

# apt-get update

Then trying the installation again.