Linux is one of the best operating systems for advanced users. It lets to take control over the entire environment and have fun. Today, let’s take a look how to monitor bandwidth on Linux.
In this tutorial, we’ll be using a tool named “iftop” (Interface TOP). It’s a real-time bandwidth monitoring tool that works on the CLI. This tool will show you real-time network usage every 2, 10 & 40 seconds. Let’s get started.
Install iftop
This tool requires two dependencies – libpcap and libncurses. So, before installing the original software package, install them first. Use the following commands:
$ sudo apt install libpcap0.8 libpcap0.8-dev libncurses5 libncurses5-dev [For Debian/Ubuntu] # yum -y install libpcap libpcap-devel ncurses ncurses-devel [For CentOS/RHEL] # dnf -y install libpcap libpcap-devel ncurses ncurses-devel [For Fedora 22+]
After the dependencies are installed, it’s time to install the real software. Use the following command(s) according to your Linux distro.
$ sudo apt install iftop [For Debian/Ubuntu] # yum install epel-release # yum install iftop [For RHEL/CentOS] # dnf install iftop [For Fedora 22+]
If your distro isn’t shown here, you can download and compile “iftop” for your distro. Download the latest TAR.GZ file from the site. Then, follow the commands in the downloaded file’s directory.
# tar -zxvf iftop-0.17.tar.gz # cd iftop-0.17 # ./configure # make # make install
Iftop usage
To start iftop, run this command in the terminal.
# sudo iftop
Here’s a sample output. Remember, iftop is a CLI tool.
If you need to monitor any specific network interface, you have to identify the target attached network interfaces on your Linux. Use these commands to identify all the attached network interface.
# sudo ifconfig OR # sudo ip addr show
Then, use this command to run iftop monitoring specifically the network interface. For example, if you have to monitor “wlp2s0”, use this command:
# sudo iftop -i wlp2s0
For turning on port display, use this command:
# sudo iftop -P wlp2s0
In order to disable hostname lookup, use “-n” flag.
# sudo iftop -n eth0
Additionally, you can use “S” or “D” to show “sources”, “destination” etc. For the in-depth and detailed explanations and tricks of commands, use this command to view the integrated tutorial.
man iftop
After you’re satisfied, you can turn off iftop by pressing “q” in the terminal window.
If the default screen of the terminal is scary, try out some of the best terminal emulators for Linux. It’ll help you relax a lot.