nload is a Linux command-line tool used to monitor network traffic and bandwidth usage in real time, using insightful graphs and traffic statistics.
In this article, we shall take a quick look at what the
nload command can do for us.
Table of Contents
- 1 Installing nload Command
- 2 Using nload Command
- 3 Display multiple devices
- 4 Set a time window
- 5 Set the refresh rate
- 6 Use a specific network device
- 7 Putting them together – Using multiple options
- 8 Configuration files for nload command
- 9 Conclusion
Installing nload Command
nload is not installed on your system, try typing the below command and examine the output.
Based on the ouput, we can check if we have
In my case (Ubuntu), I do not have it installed yet. So install it using your package manager (apt in my case).
Now, on typing
nload --help, a suitable help prompt will appear, indicating that it is now installed on your system.
Using nload Command
There are different ways of invoking nload command to perform and show the required statistics as per the option given. Let us understand that one by one.
Default config: No options
We can directly call nload command using default settings by simply typing:
This will now take you to another screen, which will show you the network visualizations in real-time, coming from various devices.
Here, as you can see, there are 3 pages available; One for each device. A device is anything which sends and/or receives internet packets on the same network, but usually, it represents a network interface device. It does not necessarily need to be a separate physical device, but can even be on the same machine!
In my case, my first device is Docker, which is not a physical device, but rather just a service which sends packets through the network. Since it is present locally, it is also listed as a device on nload command.
The statistics for this device show that currently, Docker is not sending or receiving any types of packets across a network connection, which is to be expected, as we are not running any Docker Container,
When the statistics window is open, the following key bindings serve as navigation within the window.
|Left and Right arrow keys||Switch the display to the next network device/page|
|Enter / Tab||Switch the display to the next network device/page|
|F2||Display the options window|
|F5||Save current settings to the user config file|
|F6||Reload settings from the configuration file|
|q / Ctrl + C||Quit nload command|
Now that we know how we can navigate the screen in
nload, let us move to our next device, which we can examine by pressing the right arrow key.
This shows that the second device is ens3, which is a network interface. This is the primary means through which my system is communicating with the internet, and therefore, this roughly shows the bandwidth of my network via the ens3 interface. Since there are no packets actively being transferred via this interface, there is no traffic graph.
Now that we understand the basics of using
nload, let us understand some more options for this command.
Display multiple devices
To display multiple network interfaces at the same time without the graphs, use the
-m option. This offers a view of all the interfaces in one screen.
This makes it easier to monitor the whole network more easily, using a minimal display screen without traffic graphs.
Set a time window
We can use the
-a option to set the length in seconds of the time window for average calculation. By default,
nload sets this to be 300 seconds.
nload -a DURATION
Where DURATION is the number of seconds used for calculation.
An example invocation can be:
nload -a 100
Set the refresh rate
-t interval flag sets the refresh interval of the display in milliseconds. By default,
nload sets this to be 500 seconds.
nload -t 600
Use a specific network device
We can specify network devices to use with the devices flag. The default option is set to “all”, so to change this, we need to explicitly specify the network device to the
nload devices ens3
The above command analyses network packet statistics in the
Putting them together – Using multiple options
As for other commands, we can invoke
nload using multiple options to analyze the network traffic according to our needs.
For, example, the below command will display multiple devices across all available interfaces with a time window of 400 seconds and a refresh rate of 600 milliseconds.
nload -m -a 400 -t 600
Configuration files for nload command
nload command can take advantage of some special configuration files to specify the command invocation, instead of using the command options all the time.
Such configuration files can specify the options with which
nload starts up by default. There are 2 configuration files, one for the current user, and a global system-wide configuration.
The system configuration for
nload is located at /etc/nload.conf. It is generally advised to not tamper with this file, as we have a separate user config file for user specific settings.
The user configuration file is located at $HOME/.nload, where $HOME is the Home Environment Variable, that mentions your home directory. This file may not exist by default, but
nload creates this automatically for us when we save the settings using F5. These settings will then be used by default if we type
nload, since a configuration file exists!
We can first check if the user config file exists, using this script:
#!/bin/sh if test -f $HOME/.nload; then echo "Found" else echo "Not Found" fi
There is no such file in my system, so let’s create it using
nload with the previous set of options and saving it by F5.
nload -m -a 400 -t 600
After saving it, and exiting the window, run the script again. nload must have automatically created a config file and saved settings related to our options.
Let’s examine it using any text editor.
Indeed, an existing file opens for us.
This is more or less some of the options which we specified, so this indeed works.
Now, if you want to invoke
nload with the same options, you can simply type
nload, and the options will be automatically specified in the configuration file!
In this tutorial, we learned about how we can use the
nload command to monitor network traffic. We also learned various options which can be used to set custom monitoring options and analyze our network bandwidth and traffic accordingly, and to also work with configuration files for reusability.
Hope this tutorial serves to be helpful for you to use this useful tool!