Nethogs – Monitor Linux Network Traffic Usage Per Process

There are tons of open-source network monitoring tools available for the Linux operating systems on the web. Say, you can use the iftop command to monitor bandwidth usage, netstat command, or ss command to see reports on interface statistics, or top command to watch running process on your system.

But if you are really looking for something that can give you real-time statistics of your network bandwidth per process usage, then NetHogs is the only utility you should look for.

Nethogs - Linux Per-Process Bandwidth Usage
Nethogs – Linux Per-Process Bandwidth Usage

What is NetHogs?

NetHogs is an open-source command-line program (similar to Linux top command) that is used to monitor real-time network traffic bandwidth used by each process or application in Linux.

From NetHogs Project Page

NetHogs is a small ‘net top’ tool. Instead of breaking the traffic down per protocol or per subnet, as most tools do, it groups bandwidth by process. NetHogs does not rely on a special kernel module to be loaded. If there’s suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this. This makes it easy to identify programs that have gone wild and are suddenly taking up your bandwidth.

In this article, you will learn how to install and find out real-time per-process network bandwidth usage with nethogs utility under Unix/Linux operating systems.

How to Install NetHogs in Linux Systems

This NetHogs bandwidth monitoring solution is available across numerous Linux operating systems. Based on the Linux distribution you are running, you can install nethogs from one of the following ways:

Install NetHogs in RHEL, CentOS, Rocky Linux, and AlmaLinux

To install nethogs, you must turn on the EPEL repository under RedHat-based Linux distributions and then run the following yum command to download and install the nethogs package as shown.

# yum install epel-release
# yum install nethogs

On Fedora Linux, use the dnf command as shown.

# dnf install nethogs

Install NetHogs in Ubuntu, Linux Mint, and Debian

To install nethogs, type the following apt command to install nethogs package.

$ sudo apt install nethogs

How to Use NetHogs to Monitor Bandwidth By Process

To run the nethogs utility, type the following command under red-hat-based systems.

# nethogs

On Debian-based Linux, you must have root permissions, so run with the sudo command as shown.

$ sudo nethogs
NetHogs Sample Previews:
Install Nethogs in Linux
NetHogs Preview on CentOS 6.3
Install nethogs in Ubuntu
NetHogs Preview on Ubuntu 12.10

As you see above the send and received lines show the amount of traffic being used per process. The total sent and received usage of bandwidth is calculated at the bottom. You can sort and change the order by using the interactive controls discussed below.

NetHogs Command-Line Options

Following are the nethogs command-line options. Using ‘-d‘ to add a refresh rate and ‘device name‘ to monitor specific given device or devices bandwidth (default is eth0).

For example, to set 5 seconds as your refresh rate, then type the command as.

# nethogs -d 5
$ sudo nethogs -d 5

To monitor specific device (eth0) network bandwidth only, use the command as.

# nethogs eth0
$ sudo nethogs eth0

To monitor the network bandwidth of both eth0 and eth1 interfaces, type the following command.

# nethogs eth0 eth1
$ sudo nethogs eth0 eth1

NetHogs Options and Usage

  • -d – delay for refresh rate.
  • -h – list available commands usage.
  • -p – sniff in promiscuous mode (not recommended).
  • -t – tracemode.
  • -V – show version info.

NetHogs Interactive Controls

Following are some useful interactive controls (Keyboard Shortcuts) of the nethogs program.

  • -m – Change the units displayed for the bandwidth in units like KB/sec -> KB -> B-> MB.
  • -r – Sort by the magnitude of respective traffic.
  • -s – Sort by the magnitude of sent traffic.
  • -q – Hit quit to the shell prompt.

For a full list of nethogs utility command-line options, please check out the nethogs man pages by using the command ‘man nethogs‘ or ‘sudo man nethogs‘ from the terminal.

For more information visit the Nethogs project home page.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

10 thoughts on “Nethogs – Monitor Linux Network Traffic Usage Per Process”

  1. I’ve got an unauthorized upload of about 180K/sec running, and while my browser is doing a little uploading, it’s not anywhere close to that amount. I’d like to determine what process is doing it, what files are being uploaded and maybe where they are going.

    I had a backlog of browser crash reports, but I’m sure they aren’t as much as the nearly 300Mb that’s been uploaded in my current session. Among other things, nobody wants their files being hacked, and nobody wants their bandwidth stolen by an unauthorized user or rogue process.

    Reply
  2. Getting error as:

    yum install nethogs
    Loaded plugins: fastestmirror, security
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.net.in
    * extras: centos.mirror.net.in
    * updates: centos.mirror.net.in
    Setting up Install Process
    No package nethogs available.
    Error: Nothing to do

    Reply
    • @Shantanu,

      May I know on which Linux distribution you’re trying to install? also have you installed and enabled EPEL repository on the system? if not, follow these commands.

      # yum install epel-release
      # yum install nethogs
      
      Reply
    • What do you mean by recompiled? the nethogs packages comes with epel repository all you have to do is:

      # yum install nethogs
      
      Reply
  3. HI

    I have installed the same and working fine and its a good tools but problem is PROGRAM column it showing only the destination details only its not showing the source address you can see the same issue in above screen when you run the

    sudo nethogs

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.