Linux – Monitoring Network Traffic With nethogs

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
sudo apt-get install libncurses5-dev libpcap0.8-dev
Now we have to install nethogs by typing
sudo apt-get install 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
sudo nethogs
Output:
 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. 
nethogs -h
-V: –prints Version info. 
sudo nethogs -V
-d: delay for refresh rate.
You can set 3 seconds as your refresh rate, by typing the following command:-
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:
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:
Linux-networking-commands
Picked
Technical Scripter 2020
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
Introduction to Linux Operating System
SED command in Linux | Set 2
nohup Command in Linux with Examples
mv command in Linux with examples
Array Basics in Shell Scripting | Set 1
chmod command in Linux with examples
Basic Operators in Shell Scripting