71

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!

124

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.

  • 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 9 '18 at 21:10
23

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.

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

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.

  • It is not installed in Ubuntu 18.04 as well – Binar Web Aug 3 '18 at 8:26

protected by Community Jan 8 at 17:44

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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