Monitor Network Usage On A Per-Application Basis

Today’s article is going to tell you how to use Nethogs to monitor network usage on a per-application basis. It’s actually easier than one might think and we’ll even show you how to install Nethogs on a variety of distros.

Why would you want to monitor this? Well, you may want to know which applications are eating up most of your bandwidth. Not everyone has unlimited bandwidth after all. You might also be looking for rogue applications/malware that’s using up some of your bandwidth. There are all sorts of reasons to monitor your network usage at this level. Feel free to leave a comment telling us how you intend to use Nethogs.

As stated, we’ll be using Nethogs. The man page describes it as:

nethogs – Net top tool grouping bandwidth per process

I suppose that’s mostly useful to those who know what ‘top‘ is. (There’s a future article about top and htop, when I get to it.) But, Nethogs is like a system monitor, except it’s a network monitor with some visual similarity with top. (Yes, that’s an ugly, ugly sentence.)

We’ll be using ‘sudo’ for all of these commands. It’s possible to use Nethogs without sudo, but we won’t be covering that here. If that’s something you’re interested in doing, a search engine will help you get there.

Monitor Network Usage:

Nethogs is a terminal-based application. As such, you’ll need an open terminal. Just press CTRL + ALT + T and your default terminal emulator should open right up.

Once your terminal is open, you can go ahead and install Nethogs. Pick the command that works with your system’s package manager.

Debian/Ubuntu:

RHEL/CentOS (will need to enable EPEL):

Fedora:

Arch/Derivatives: 

Once you have Nethogs installed, you can check the help files. In this case, the help files are better than the man files (I think) so just enter the following into your terminal:

Now, to run Nethogs, we’ll use sudo and just run it in the terminal. Believe it or not, this mode is generally just fine for anything you’re going to do.

That’ll open Nethogs and start monitoring your network usage on a per-application basis. It looks something like this:

Nethogs running in the terminal.
As you can see, bandwidth monitoring on a per-application basis. Tada!

Now, if you’re going to leave it open, you can change the refresh rate. That’s done with the -d <seconds> flag. If you want it to refresh every 15 seconds, your command would look like this:

By the way, if you want to exit Nethogs, you just press Q and it closes – like top and htop do.

If you want, you can specify the network interface you want to use. It doesn’t require any flags, just the network interface name. (Read Also: how to change your network interface name.) An example of that command would be:

While the application is running, you can do some sorting/display changes with the M, R, and S keys. But it’s usually not all that complicated and sorting isn’t needed. If you’re dealing with hundreds of collections, then you may want to start sorting. Really, that’s about all you’ll ever need.

Closure:

And there you have it! You have another article to read. This one is about monitoring your network usage on a per-application basis, a pretty handy skill/tool to have. It’s pretty easy and the output is clear enough for all but the newest Linux users. If you find the tool useful, or already use the tool, please feel free to comment.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe to Newsletter!
Get notified when new articles are published!
We promise to never share your email!
icon

Author: KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.