Skip to content
Related Articles

Related Articles

Linux – Monitoring Network Traffic With nethogs
  • Difficulty Level : Medium
  • Last Updated : 19 Feb, 2021

NetHogs is similar to Linux top command which is an open-source command-line program, that is used for monitoring network traffic in Linux. But do you ever wanted to notice which application in your system is eating up your bandwidth, Then Nethogs is one of the good choices. Nethogs will help you find out what bandwidth an PID is taking up as Nethogs groups bandwidth by process instead of breaking the traffic down per protocol or per subnet. . It is a great choice if you want to identify which program in your Linux system is taking up more bandwidth.

Installing nethogs in Debian-based Linux:

Before installing nethogs you need to install libncurses5-dev and libpcap0.8-dev on Debian-based machines such as Kali Linux because Nethogs depends on ncurses for the text-based interface and libpcap for user-level packet capture.

sudo apt-get install libncurses5-dev libpcap0.8-dev
How to Monitor Network Traffic in Linux With nethogs

sudo apt-get install libncurses5-dev libpcap0.8-dev

Now we have to install nethogs by typing

sudo apt-get install nethogs 
How to Monitor Network Traffic in Linux With nethogs

sudo apt-get install nethogs

How to use nethogs in Debian based distros:



After installing Nethogs we have to type sudo nethogs or normal nethogs if you are already a root user because it won’t work without root privileges. 

sudo nethogs
How to Monitor Network Traffic in Linux With nethogs

sudo nethogs

Output:

How to Monitor Network Traffic in Linux With nethogs

 Nethogs Interface on my linux system

So as we can see above screenshot is showing a clear view of the program that is consuming my network bandwidth. We can easily understand from the above screenshot that nethogs display us the details about the process id of the program which is currently using the bandwidth, the name of the program which is consuming this bandwidth, the device that is being monitored, sent data details, received data details and all total.

NetHogs Command-Line Options:

-h: display available commands usage.
 

How to Monitor Network Traffic in Linux With nethogs

nethogs -h

-V:prints Version info.
 

How to Monitor Network Traffic in Linux With nethogs

sudo nethogs -V

-d: delay for refresh rate.

You can set 3 seconds as your refresh rate, by typing the following command:-

How to Monitor Network Traffic in Linux With nethogs

sudo nethogs -d 3

 
You can also monitor specific device (wlan0) or multiple network (wlan0 and pan1) bandwidth, by typing the following command:



sudo nethogs wlan0 pan1

-p: sniff in promiscuous mode (not recommended).

It will help you to sniff in promiscuous mode but according to the nethog’s manual pages it is not recommended, but you can use it by typing the following command:

sudo nethogs -p wlan0

-t: tracemode

Trace mode will output the connections one by one, to use tracemode you have to give the following command:

How to Monitor Network Traffic in Linux With nethogs

sudo nethogs -t wlan0

And for more information, you can check the manual of nethogs by typing man nethogs and it will give output like this:

nethogs manual

NetHogs Interactive Controls:

My Personal Notes arrow_drop_up
Recommended Articles
Page :