Linux Nethogs: Check Network Usage by Process

Updated: Mar 3

Nethogs is a Linux command that allows us to view network usage of a running process in realtime. Nethogs sorts the output by process and network bandwidth usage. We can quickly find out which process is using more bandwidth. This is an important command when we troubleshoot network problems in realtime.

How to install nethogs on Ubuntu or Debian

Nethog is not installed on Ubuntu by default. Nethogs is available in the official package repository of Ubuntu/Debian. We can easily install nethogs with the APT command.

$ sudo apt update

$ sudo apt install nethogs

How to install nethogs on CentOS or Redhat:

Nethogs is not installed on CentOS or Redhat by default. Nethogs is available in the EPEL repository. We can easily install nethogs from the EPEL repository with the YUM package manager.

$sudo yum install nethogs

How to use nethogs to check network usage by process?

We can run command nethogs to start nethogs with root user. The network upload (sent) and download (received) speeds for each process is listed. The network interface for each process is listed.

The owner of the process and also the PID is listed. If we have any process which is eating up network bandwidth unnecessarily, we can just kill the process using the PID.

Nethogs automatically updates the information just like top and htop does.

How to change display modes from kb/s to mb/s in nethogs?

By default, nethogs displays the network download and upload speeds in kilobytes/s (kb/s). This is one of the display modes of nethogs. There are 4 display modes of nethogs, the default kb/s, total bytes used (b), total kilobytes used (kb), total megabytes used (mb). We can press the m key on our keyboard to change this.

How to use nethogs to monitor network interface bandwidth?

$ sudo nethogs eth0

$ sudo nethogs –d 5 eth0 ( 5 is the interval)

How to use nethogs in interactive mode?

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

  • -m : Change the units displayed for the bandwidth in units like KB/sec -> KB -> B-> MB.

  • -r : Sort by magnitude of respectively traffic.

  • -s : Sort by magnitude of sent traffic.

  • -q : Hit quit to the shell prompt.

Related Post:

Linux Command: Check Network Status on Linux