Hello friends. Monitoring the network can be a very useful thing to do and can find problems. Besides that, it is always good to keep track of network usage. Therefore, we will show you how to install and use Nethogs on Ubuntu 20.04. This simple tool allows you to track network usage.
In the Github profile of this tool, we find the following definition
NetHogs is a small ‘net top’ tool. Instead of breaking the traffic down per protocol or per subnet, like most tools do, it groups bandwidth by process.
Thanks to this tool, we can find out which processes and applications consume the most bandwidth. In administrative situations, it is quite useful to identify network abuses.
Since NetHogs heavily relies on /proc, most features are only available on Linux. NetHogs can be built on Mac OS X and FreeBSD, but it will only show connections, not processes.
So, let’s get started.
Install Nethogs on Ubuntu 20.04
Nethogs is a mature piece of software included in most Linux distributions. And this includes Ubuntu 20.04 and derivatives, so to install it, just run the following command
sudo apt update sudo apt install nethogs
This way we will be able to use it from the terminal.
Using Nethogs on Ubuntu 20.04
The most common way to use it is simply to run it with root permissions as follows:
sudo nethogs
There you will notice how the set of applications that are using the network are grouped by processes.
It is useful to give the program a refresh rate. This rate is measured in seconds and can be specified with the -d
option. For example to indicate that every 5 seconds the monitoring should be refreshed.
sudo nethogs -d 5
Another useful thing to do is to specify which network interface to monitor.
sudo nethogs -d 5 eth1
This way only the network interface eth1
is taken into account, but you can also add more than one.
sudo nethogs -d eth1 eth2
As you can see, it is quite simple to use.
Also, you can install a graphical interface called nethogs-qt
for better integration.
Conclusion
These kinds of tools, although simple, can be very useful to see which application consumes a lot of bandwidth. This is useful in a home environment but in a production environment, it can be vital.
Enjoy it.