70

Following update of my Kubuntu, I'm not able to monitor my network consumption using nethogs:

sudo nethogs enp1s0
creating socket failed while establishing local IP - are you root?

Kernel

$ uname -a
Linux xyz 4.2.0-27-generic #32-Ubuntu SMP Fri Jan 22 04:49:08 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Release

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.10
Release:        15.10
Codename:       wily

Version

$ nethogs -V
version 0.8.0

2 Answers2

101

This is solved by version 0.8.1.

As it's not available in repo nor PPA you need to build it (it is really easy and quickly done).

Fetch and extract the most recent version (as of August 2016, v0.8.5)

wget -c https://github.com/raboof/nethogs/archive/v0.8.5.tar.gz
tar xf v0.8.5.tar.gz 
cd ./nethogs-0.8.5/

Install dependencies and build

sudo apt-get install libncurses5-dev libpcap-dev
make && sudo make install 

Check and run

nethogs -V
sudo nethogs
edwinksl
  • 23,789
  • 10
    Better with checkinstall that we can manage it easily, also avoiding conflict with the default repo from ubuntu. Just check license and version to update this command: make && sudo -k checkinstall --pkgsource="https://github.com/raboof/nethogs/" --pkglicense="GPL2" --deldesc=no --nodoc --maintainer="$USER\\<$USER@$HOSTNAME\\>" --pkgarch=$(dpkg --print-architecture) --pkgversion="0.8.2" --pkgrelease="SNAPSHOT" --pkgname=nethogs make install. – Aquarius Power Feb 11 '16 at 02:17
  • @AquariusPower thank, I'm not familiar with checkinstall. BTW didn't you forget a && before the make install? – Édouard Lopez Feb 12 '16 at 09:43
  • 3
    @ÉdouardLopez checkinstall will call make install and track everything it does to create a deb package :) – Aquarius Power Feb 13 '16 at 00:29
  • 2
    You can use checkinstall if you want it to update when the next versions roll in – GuySoft Apr 02 '16 at 10:35
  • This worked, but after running this answer's command, nethogs -V still reports my previous version, v0.8.0. sudo nethogs -V reports v0.8.1, and opening a new terminal and running nethogs -V reports v0.8.1. I'm just curious why. – Tyler Collier Apr 03 '16 at 20:59
  • 1
    @TylerCollier the $PATH variable was probably updated and need to be reexported so you can access correct version. You can install the synaptic package and check where it is installed with which nethogs, then reinstall from source and check again to see if the path changes. – Édouard Lopez Apr 04 '16 at 08:20
  • 2
    I can confirm the command from @AquariusPower works in gNewSense 4 Ucclia (upgraded into Debian Jessie) perfectly. I am using NetHogs 0.8.1 now. My binary of nethogs here belongs to /usr/local/sbin/nethogs. Thank you. – Ade Malsasa Akbar Jun 05 '16 at 06:37
  • 1
    Note that if you originally installed nethogs v0.8.0 via apt-get or another package manager then this method does not remove it. E.g. on my Ubuntu 14.04 system nethogs v0.8.5 is installed in /usr/local/sbin/nethogs, but v0.8.0 is still available in /usr/sbin/nethogs – cfogelberg Aug 05 '16 at 07:25
  • @cfogelberg edwinksl the bug is supposed to be fixed in 0.8.1, if that's not the case, please repoen the issue – Édouard Lopez Aug 05 '16 at 10:39
  • 1
    @ÉdouardLopez I believe it is fixed in 0.8.1, the latest version is 0.8.5 though so I just made a quick edit to the answer so that other users who just used these instructions would default to installing the (current) latest version with the idea that later is better and presumably has other bug fixes too – cfogelberg Aug 05 '16 at 13:06
6

You can also build from latest source code in the git repository. You still need to install the dependency packages first. After building you can run nethogs from your current directory:

sudo apt-get install libncurses5-dev libpcap-dev
git clone --depth 1 https://github.com/raboof/nethogs.git
cd nethogs
make
sudo ./src/nethogs

You can also find the instructions on the Nethogs project page.

Jocelyn
  • 287
D.Snap
  • 333
  • 6
    Please do not just dump a bunch of commands here but also explain what they do and why you think they solve the problem. Thanks. – Byte Commander Mar 24 '16 at 08:22
  • 3
    I think is self explanatory, 1 - install the software dependencies, 2 - download the latest source from Git, 3 - goes to the newly created directory, 4 - compiles the program, 5 - runs the program – D.Snap Mar 25 '16 at 02:34
  • 2
    I've added the requested explanation in the answer and a link to the official instructions. – Stephan Henningsen Mar 31 '16 at 08:41
  • 2
    Not everybody has git nor want's to install it. Dowloading the tar and building is good enough. – m3nda Apr 12 '16 at 23:58
  • 2
    the current repo compiles the executable into the src/ subdirectory, so the last command needs to be sudo src/nethogs – drevicko May 03 '16 at 21:52