Linux which process use network

Check Network Usage by Process with Linux Nethogs command

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
  • How to install nethogs on CentOS or Redhat
  • How to use nethogs to check network usage by process?
  • How to change display modes from kb/s to mb/s in nethogs?
  • How to use nethogs to monitor network interface bandwidth?
  • How to use nethogs in interactive mode?

Understanding nethog command in Linux

The nethog command is a utility for monitoring network traffic in real time. The output of the command shows details about the data being transferred, including the source and destination IP addresses, port numbers, and protocol information.

The nethog command can be used to monitor traffic for a specific interface, process, TCP connection, or UDP connection. The command can also be used to generate a report of network traffic for a specific time period.

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.

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.

How to use nethogs to check network usage by process in Linux?

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.

This will display the network bandwidth used by each process on the eth0 network interface.

The nethogs command can be useful for troubleshooting network issues. If a process is using a lot of bandwidth, it can be identified with the nethogs command.

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).

Читайте также:  Linux command line and gui

We can press the m key on our keyboard to change this.

How to use nethogs to monitor network interface bandwidth in Linux?

$ 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.

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

howtouselinux.com is dedicated to providing comprehensive information on using Linux.

We hope you find our site helpful and informative.

Источник

Check network usage per process in Linux

Slow network connections are very annoying and can lead to huge downtime. Linux administrators should keep an eye on what is running on their network and taking much network bandwidth. Monitoring network usage can help to identify the issue and keep network traffic running.

In this article, we will explain a few tools that will allow you to check network usage per process in your Linux system. These tools include IPTraf, Iftop and Nethog. With the help of these tools, you can identify which process or port number is draining much of the network bandwidth.

Note that we have explained the procedure on Ubuntu 18.04 LTS system.

IPTraf

IPTraf is an open-source command-line network monitoring tool that allows monitoring of various network statistics such as TCP, UDP, Ethernet load, ICMP, etc. We can use it to view network usage of a processes running in Linux.

Installation

IPTraf is included in the official repositories of the Ubuntu system. Therefore, we can install it using the apt or apt-get command.

Open the Terminal by using Ctrl+Alt+T shortcut and then run this command as sudo to install IPTraf:

During installation, the system might ask for confirmation by providing with Y/n option. Hit y to confirm and then wait for a while until the IPTraf is installed on your system.

Usage

To use IPTraf, run this command in Terminal:

When you run the above command, you will see the output similar to below. The output shows the network statistics against the source IP address and port number. However, it does not show the specific process which is using the bandwidth.

For some common ports, you can easily guess the process name, such as FTP port number 21, telnet port number 23 and so on. However for some less known ports, to find out a process running against it, use the following netstat command:

For instance, we want to find out the process name against the port number 443. In that case, the command would be:

The output shows the process name “firefox” running against the port number 443.

To view network statistics for a particular interface, use –i followed by interface name:

To view more information about IPTraf, see the man page or use help as follows:

Iftop

Iftop is similar to the top command except it is used for monitoring network usage instead of processor usage. It is an open-source command-line tool that displays current bandwidth usage of a specific interface. Similar to the IPTraf, it also does not displays the process which is using the bandwidth.

Читайте также:  Форматирование файловых систем linux

Installation

Iftop is available in the official repositories of Ubuntu. Therefore, we can install it simply using the apt or apt-get command.

In the Terminal, run this command as sudo to install Iftop:

During installation, the system might ask for confirmation by providing with Y/n option. Hit y to confirm and then wait for a while until the Iftop is installed on your system.

Usage

To use Iftop, run this command in Terminal:

It displays the sent and received bytes within three different time intervals. At the end, it displays cumulative sent and receive bytes.

To view port number in the display, use –p option as follows:

To view information about the specific interface, use –i option as follows:

To view more information about iftop, see the man page or use help as follows:

Nethogs

Nethogs is an open-source command-line utility that allows viewing network usage of a process running in the Linux system. Unlike the above IPTraf and Iftop tools, Nethogs sorts the output by process and bandwidth usage. Therefore, it comes handy when you need to find which process is using more bandwidth.

Installation

It is also available in the official Ubuntu repositories. Therefore to install it, use the apt or apt-get command as follows:

Wait for a while until the installation of Nethogs is completed.

Usage

To use Nethog for checking network usage, simply type nethogs in the Terminal:

The output displays the sent and received traffic used by different processes. In the end, it displays the total traffic sent and received by all processes.

To view network usage on a specific interface, use the Nethog command as follows:

To specify refresh interval, use –d option. For instance, to set 7 seconds as refresh interval, run this command:

That is all there is to it! In this article, we have learned how to install and use IPTraf, Iftop, and Nethog in Linux. Through these tools, you can easily check the network usage per process in your Linux system.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

Источник

In Ubuntu, how do I figure out which process is a network pig [closed]

Using top it’s easy to identify processes that are hogging memory and cpu, but ocasionally I see my computer’s network activity spike, but I’m unable to determine which process is generating the activity. Where is the right place to look for this information?

6 Answers 6

You can also take a look at «NetHogs»: http://nethogs.sourceforge.net/. Little yet very handy utility. Especially if you want to find out which process is taking the bandwidth.

Aside of «nethogs», if you want to limit rate of any software that does not have such functionality built-in, then look at «trickle»: monkey.org/~marius/trickle.

You can install several applications to monitor network traffic in real time. NTOP, tcpdump, trafshow, iptraf.

I would go with NTOP or IPTRAF. But that’s just a personal taste.

Also, with Linux’s netstat you can use the -p flag to see how many connections is a process using.

Читайте также:  Linux посмотреть путь символьной ссылки

You can also use iftop. In Ubuntu you can install it by typing in terminal: sudo aptitude install iftop . To use type: sudo iftop -i eth0 , where eth0 is your network interface.

The package ‘nmon’ provides a comparable tool to top. The design’s a bit different since the kernel doesn’t provide excellent statistics via /proc.

Description: performance monitoring tool for Linux nmon is a systems administrator, tuner, benchmark tool. It can display the CPU, memory, network, disks (mini graphs or numbers), 
Description: displays bandwidth usage information on an network interface iftop does for network usage what top(1) does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth 

Источник

Linux commands to get list of processes which use network bandwidth

Default featured post

Earlier in one of the post I already explained about process management in Linux and how to monitor and determine resource usage of each command such as process time, RAM, etc. In this post, I will demonstrate about how to get list of processes which use network bandwidth. In Linux many applications and commands are available either in GUI or command line for network management. What I explain here is really small part of the ocean (network commands). For getting list of processes that use bandwidth, you can use nethogs , iftop , netstat and other commands. Here I cover just three of them which mean nethogs , iftop , and netstat .

Nethogs

This command is similar to ‘top’ command in process management but it monitors traffic on network based on assigned network card. For installing nethogs type the following command in command line of Debian based distros.

$ sudo apt-get install nethogs

After installing it, you could run it like below command,

First of all keep in your mind that for executing this command you should have root permission and in above command traffic of ‘wlan0’ network (wireless card) is monitored. This command shows live overall traffic consumption of processes that use network and updates statistics each second exactly like top command.

Iftop

This command is equal command to ‘top’ command except that this command is for network monitoring. For installing iftop command type the following command in console.

$ sudo apt-get install iftop

Like nethogs command, this command also needs root permission to execute. In addition, if you do not identify your network card, by default the command monitors ‘eth0’ card. Therefore, for using iftop to listen to another network follow below example,

In comparison with nethogs, iftop gives you more details about network traffic and in addition, this command monitors those system processes that use network as well not like nethogs that by default just monitor user processes.

Netstat

Netstat is also useful tool to monitor network traffic, however it does not have live monitor ability and whenever you run this command it just gives list of processes that use network and quit. The good point about this command is that, netstat does not need root permission to run and is suitable for users who do not have access to root account. In most of Linux distros this command is also pre-installed but if it is not installed you can install it by following command,

$ sudo apt-get install netstat

For getting list of processes follow below example,

For more information please refer to following links,

Источник

Оцените статью
Adblock
detector