How to Display Network Traffic in the Terminal?

Network traffic in Linux refers to the data packets transmitted and received over a network interface. It encompasses the flow of information, including data transfers, network requests, and responses between devices.

Linux administrators monitor the network traffic to analyze network performance, detect anomalies, troubleshoot connectivity issues, and identify potential security threats. By examining network traffic in the Linux terminal, administrators gain visibility into the volume, patterns, and behavior of data traversing their network, enabling them to optimize performance, ensure reliability, and safeguard against unauthorized access or malicious activities.

This post will list all the possible commands/methods to display network traffic in Linux. As a reference, the commands in this post will be practiced on Ubuntu 22.04. However, the commands are generic and apply to all Linux distributions.

How to Display Network Traffic in Terminal?

Certainly, various command line utilities display the network traffic in Linux. Some of these commands are pre-installed on Linux. However, others can be installed using, and we will also provide the installation commands. So, let’s dig into these commands individually and examine how they portray network traffic.

Method 1: ip Command

The ip command is a powerful tool for network configuration and management. You can use it to display information about network interfaces and their statistics. To view network traffic statistics, you can use the following command:

$ ip -s link

How to Display Network Traffic in the Terminal? |

The output of the command shows the information about the network interfaces, i.e., the bytes, packets, errors, etc., are displayed for each RX and TX of the network interfaces.

Method 2: ifconfig Command

The ifconfig command displays information about network interfaces, including their IP addresses, MAC addresses, and current network traffic statistics. However, it is considered deprecated in many Linux distributions in favor of ip command.

Install ifconfig Utility

In recent distributions, the IP command is not equipped by default. Use the commands to install the support:

$ sudo apt install net-tools     #Debian/Ubuntu 
$ sudo dnf install net-tools     #Fedora 
$ sudo yum install net-tools     #CentOS/RHEL 
$ sudo pacman -S net-tools       #Arch Linux


$ ifconfig

How to Display Network Traffic in the Terminal? |

Being the older version of the IP command, the output of the ifconfig command is the same.

Method 3: netstat Command

This command shows network connections, routing tables, and various network statistics. The netstat command can be executed in the following manner:

$ netstat

How to Display Network Traffic in the Terminal? |

The output represents the information about active network connections, including local and remote IP addresses, ports, and connection status.

Method 4: nethogs Command

This command provides real-time monitoring of network traffic per process. It shows the network bandwidth each process uses on your system. The nethogs utility does not come by default on Linux systems. Thus, before using, ensure you have installed it on your Linux system:

Install nethogs on Linux

To install nethogs, you may need to use one of the commands as per your Linux distribution:

$ sudo apt install nethogs   #Debian/Ubuntu
$ sudo dnf install nethogs   #Fedora
$ sudo yum install nethogs   #CentOS/RHEL
$ sudo pacman -S nethogs     #Arch Linux


Now, if you have installed it in your system, you can use the following command to check the network traffic:

$ sudo nethogs

How to Display Network Traffic in the Terminal? |

The output of the nethogs command displays a list of processes or applications using network bandwidth, along with their corresponding network usage in terms of incoming and outgoing data rates.

Method 5: iftop Command

The iftop command provides real-time bandwidth monitoring of network interfaces. It displays a continuously updated list of network connections and their corresponding bandwidth usage. Like nethogs, this utility needs to be installed before it is used on any other system.

Install iftop on Linux

The installation command depends on the Linux distribution you are using:

$ sudo apt install iftop    #Debian/Ubuntu
$ sudo dnf install iftop    #Fedora
$ sudo yum install iftop    #CentOS/RHEL
$ sudo pacman -S iftop      #Arch Linux


The iftop is executed in the following way to display the network traffic on Linux:

$ sudo iftop

How to Display Network Traffic in the Terminal? |

The output of the nethogs command in Linux shows real-time network usage per process, indicating the applications or processes consuming network bandwidth and their corresponding data rates.

Method 6: iptraf Command

The iptraf command in Linux is a network monitoring utility that provides real-time network statistics and traffic analysis. It allows administrators to monitor various aspects of their network, including IP traffic, network connections, and interface statistics.

Install iptraf Utility

The iptraf utility can be installed on the Linux systems as follows:

$ sudo apt install iptraf    #Debian/Ubuntu
$ sudo yum install iptraf    #Fedora
$ sudo dnf install iptraf    #CentOS/RHEL
$ sudo pacman -S iptraf      #Arch Linux


Once it is obtained, use the iptraf command in the following manner to get the network traffic:

$ sudo iptraf

How to Display Network Traffic in the Terminal? |

Now, depending upon the users requirements, they can navigate through the menu to get the information what they want.

Method 7: bmon Command

The bmon displays real-time network bandwidth usage on multiple interfaces. It provides a simple visual representation of network traffic. This utility does not come by default on most Linux systems. So, we need to get it first.

Install bmon Utility

Run the command to install the bmon utility on the Linux system as per the relevant command written below:

$ sudo apt install bmon    #Debian/Ubuntu
$ sudo dnf install bmon    #Fedora
$ sudo yum install bmon    #CentOS/RHEL
$ sudo pacman -S bmon      #Arch Linux


Now, run the command stated below to display the network traffic:

$ sudo bmon

How to Display Network Traffic in the Terminal? |

That’s how you can use various command-line utilities to monitor/display network traffic on Linux-based systems.

Wrap Up

Network traffic in Linux refers to data packets transmitted and received over network interfaces. It is crucial for Linux administrators to monitor network traffic to analyze performance, troubleshoot connectivity issues, and detect potential security threats.

This post has listed the usage/installation of various command line utilities to display network traffic in Linux terminals. The commands used to serve the purpose are ip, ifconfig, netstat, nethogs, iftop, iptraf, and bmon.

Keep visiting Linux Genie to keep yourself updated with Linux.

Print Friendly, PDF & Email