109

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 Answers3

183

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.

edwinksl
  • 23,789
  • 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? – Duncan Gravill Aug 17 '16 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 '16 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

    – obesechicken13 May 09 '18 at 21:10
41

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.

JamesThomasMoon
  • 273
  • 2
  • 14
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.

mc0e
  • 328
  • 2
  • 11