How to Monitor Network Traffic using nethogs

29/12/2020
Chưa phân loại
nethogs is a networking monitoring tool for Linux. Just like top or htop, nethogs can monitor network traffic in real time. nethogs can monitor any specific network interface or all the networking interfaces on your computer. nethogs shows bandwidth usage per process on your computer in real time.

In this article, I am going to show you how to install and use nethogs to monitor network traffic on Linux. So, let’s get started.

Installing nethogs on Ubuntu/Debian:

nethogs is not installed on Ubuntu/Debian by default. But, it is available in the official package repository of Ubuntu/Debian. So, you can easily install nethods with the APT package manager.

First, update the APT package manager cache with the following command:

$ sudo apt update

Now, install nethogs with the following command:

$ sudo apt install nethogs

nethogs should be installed.

Now, to check whether nethogs is working, run the following command:

$ nethogs -V

As you can see, it’s working correctly.

Installing nethogs on CentOS 7:

nethogs is not installed on CentOS 7 by default. But nethogs is available in the EPEL repository of CentOS 7. So, you can easily install nethogs from the EPEL repository with the YUM package manager.

First, enable EPEL repository with the following command:

$ sudo yum install epel-release

Now, press y and then press <Enter>.

Now, press y and then press <Enter> to accept the GPG key of the CentOS 7 repository.

EPEL repository should be enabled.

Now, run the following command to install nethogs with the YUM package manager.

$ sudo yum install nethogs

Now, press y and then press <Enter>.

Now, press y and then press <Enter> to accept the GPG key of the EPEL repository.

nethogs should be installed.

Now, to check whether nethogs is working, run the following command:

$ nethogs -V

nethogs is working perfectly.

Installing nethogs on Arch Linux:

nethogs is not installed on Arch Linux by default as well. But, nethogs is available in the official package repository of Arch Linux. So, you can easily install nethogs on Arch Linux using the Pacman package manager.

$ sudo pacman -Sy nethogs

Now, press y and then press <Enter> to continue.

nethogs should be installed.

Now, run the following command to check whether nethogs is working.

$ nethogs -V

As you can see, nethogs is working perfectly.

Using nethogs:

Now that you have nethogs installed, you’re ready to monitor your network traffic with nethogs.

If you want to monitor the network traffic of all the network interface of your computer, you can run nethogs as follows:

$ sudo nethogs -a

nethogs should start. As you can see, the network upload (sent) and download (received) speeds for each process is listed. The network interface each process is using is also listed here. The owner of the process and also the PID is listed here. If you have any process which is eating up network bandwidth unnecessarily, you can just kill the process using the PID.

nethogs should automatically update the information just like top and htop does.

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). You can press the m key on your keyboard to while nethogs is running to cycle through these display modes.

The default display mode of nethogs. It shows the network download and upload speed in kilobytes/s (kb/s).

Another display mode of nethogs. In this display mode the total network usage per process in kilobytes (kb) is displayed. Also the total network usage of every process (in kb) is displayed as well.

In this display mode the total network usage per process in bytes (b) is displayed. Also the total network usage of every process (in b) is displayed as well.

In this display mode the total network usage per process in megabytes (mb) is displayed. Also the total network usage of every process (in mb) is displayed as well.

You can close nethogs network monitor with <Ctrl> + c.

If you want to monitor a specific network interface using nethogs, you can easily do it.

For example, let’s say, you want to monitor the network interface ens33 with nethogs. To do that, start nethogs network monitor with the following command:

$ sudo nethogs ens33

NOTE: You can list all the network interfaces of your computer with the ip a command.

Now, only the ens33 interface should be monitored.

So, that’s how you use nethogs on Linux to monitor network traffic. Thanks for reading this article.

Sandclock IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, Sandclock IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Testing REST API Using Postman

Postman is a software which you can use to test REST APIs. Postman has an easy to use graphical user interface. It also...
29/12/2020

Heatmaps and Colorbars in Matplotlib

Data visualization is one of the most crucial step in Data Science (or any other science, for that matter). We, as humans,...
28/12/2020

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu

Các tính năng chính : ADDIPTOSERVER SHOWAVAILABLEPROXIES ADDUSER ASSIGNIPTOUSER SHOWSUSERSEXPIREDATE MODIFYUSERSEXPIRYDATE SHOWUSERSPROXYINFO DELETEIPFROMSERVER DELETEUSERPROXY DELETEUSER SHUTDOWNPROXY STARTPROXY EXPORTAVAILABLEPROXY EXPORTUSERSPROXY ADDBLACKLIST SHOWBLACKLIST DELETEBLACKLIST EXIT RANDOMPROXIES CHANGEIP-MULTIPLIER Cài...
20/10/2021
Bài Viết

Bài Viết Mới Cập Nhật

Hướng dẫn chuyển đổi windows server windows evaluation to standard và active windows server 2008 + 2012 + 2016 + 2019
26/10/2021

How to Update Ubuntu Linux
24/10/2021

Squid Proxy Manager cài đặt và quản lý Proxy Squid tự động trên ubuntu
20/10/2021

Hướng dẫn cài đặt Apache CloudStack 4.15.2.0
19/10/2021

Hướng dẫn ký file PDF bằng chữ ký số (chữ ký điện tử) và sửa lỗi mới nhất 2021 foxit reader
19/10/2021