Networking

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:

sudo apt install nethogs

RHEL/CentOS (will need to enable EPEL):

yum install epel-release
yum install nethogs

Fedora:

dnf install nethogs

Arch/Derivatives: 

sudo pacman -Sy nethogs

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:

nethogs -h

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.

sudo nethogs

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

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:

sudo nethogs -d 15

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:

sudo nethogs enp2s0

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.

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.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

5 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

5 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

6 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

6 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

6 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

6 months ago