105

Was netstat removed in 16.04? Is there an alternative to netstat available in 16.04? Or how do I install netstat in 16.04?

I am running an ubuntu:16.04 container in docker for Windows, it seems that netstat is no longer available... It is available in an ubuntu:14.04 container.

I have tried installing netstat with apt-get but with no luck...

apt-get update

...

apt-get install netstat
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package netstat

It might be that the solution to this is very obvious to most devs, however Linux is very new to me... enjoying it a lot!

3 Answers 3

177

As you can see from https://packages.ubuntu.com/xenial/amd64/net-tools/filelist, netstat is provided by the net-tools package. Therefore, you can get netstat by running:

sudo apt update
sudo apt install net-tools

net-tools is probably not installed by default in the Docker image for Ubuntu 16.04 to keep the image size as small as possible.

3
  • Thanks @edwinksl. It seems though that netstat was included as default in 14.04. If it is not included as default in 16.04 do you know if an alternative is included as default in 16.04? Or was it not included in 16.04 simply to make 16.04 a more essential unit? Aug 17, 2016 at 22:48
  • 2
    @DuncanGravill It is provided by default on my Ubuntu 16.04 desktop. It may have been excluded from the Docker image that you are using to keep the image size manageable. In any case, it is no big deal and you can just install it if it is missing.
    – edwinksl
    Aug 17, 2016 at 22:49
  • Not only am I not able to find and install net-tools on 16.04 xenial ubuntu, I'm also not able to use sudo since they removed that from the docker image. Nvm needed apt-get update May 9, 2018 at 21:10
39

In my opinion is better to begin adapting yourself to new tools.

ss is auto-defined as "another utility to investigate sockets"

ss -ltu

Will show listening sockets for tcp and udp.

For more information you can use ss --help or man ss. The program ss can be found in the iproute2 package.

6
  • What about nstat , Is that a good one ?
    – luv.preet
    Apr 21, 2017 at 23:12
  • Thanks. netstat is obsolete, you should use ss (man netstat)
    – redochka
    Aug 9, 2017 at 6:26
  • netstat is deprecated for linux, but still used on other operating systems. Good tip for use of ss.
    – Ejoso
    Sep 7, 2017 at 16:55
  • Which apt package provides ss? Jan 8, 2019 at 7:01
  • 1
    @JamesThomasMoon1979 Please don't ask questions in the comments section. iproute2 is what you are looking for.
    – user68186
    Jan 8, 2019 at 17:36
2

The version of ubuntu that's provided for use in containers has much less installed in it than a typical desktop installation.

Netstat is still available in Ubuntu 16.04 (via the net-tools package). It's just that that package isn't installed inside docker containers by default.

1
  • It is not installed in Ubuntu 18.04 as well
    – Binar Web
    Aug 3, 2018 at 8:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.