“iftop” Command Linux Examples
“iftop” is a network monitoring command in Linux that displays real-time information about your network bandwidth usage. This command can easily be installed on any Linux distribution and can be used very conveniently. This article will be based on the installation method of this command, followed by a few of its use cases.
Installing the “iftop” Command in Linux:
Since the “iftop” command is not installed by default on Linux, therefore, we will first install it with the following command:
When the “iftop” command is installed on your Linux system, you will be able to use it to check your network bandwidth usage.
Syntax of the “iftop” Command in Linux:
The syntax of the “iftop” command is as follows:
These options can be explored by looking at the help manual of the “iftop” command in the manner shown below:
The help manual of the “iftop” command is shown in the following image:
Examples of the “iftop” Command in Linux:We will be exploring some of the options that can be used with the “iftop” command in the examples discussed below:
Example # 1: Check the Bandwidth Usage in Linux:
If you simply want to check the network bandwidth usage of your machine, then you can use the “iftop” command in the following manner:
When you execute this command, it will take you to a new interface where it will show you all of its calculations, as shown in the image below:
You will be able to exit this interface by pressing Ctrl+ C, as shown in the following image:
Example # 2: Display the Bandwidth in Bytes in Linux:
If you want to display your network bandwidth in Bytes, then you can modify the “iftop” command as follows:
Again, you will be taken to a new interface upon the execution of this command where you will be able to see the bandwidth in Bytes as shown in the image below:
You will be able to exit this interface by pressing Ctrl+ C, as shown in the following image:
Example # 3: Show Port Numbers along with Hostnames in Linux:
If you also want the port numbers to be displayed along with the hostnames in the output, then you can use the below-shown variation of the “iftop” command:
You can easily see from the image that now the port numbers are displayed along with the hostnames in the output of the “iftop” command.
You will be able to exit this interface by pressing Ctrl+ C, as shown in the following image:
Example # 4: Sort the Output by Source Address in Linux:
If you want the output of the “iftop” command to be sorted by the source address, then you can use this command in the manner shown below:
Running the “iftop” command in this manner will sort the output according to the source address as shown in the image that follows:
You will be able to exit this interface by pressing Ctrl+ C, as shown in the following image:
Example # 5: Sort the Output by Destination Address in Linux:
If you want the output of the “iftop” command to be sorted by the destination address, then you can use this command in the manner shown below:
$ sudo iftop –o destination
Running the “iftop” command in this manner will sort the output according to the destination address as shown in the image that follows:
You will be able to exit this interface by pressing Ctrl+ C, as shown in the following image:
Conclusion:
By going through today’s guide, you will have a piece of good knowledge about using the “iftop” command in Linux. You can also explore its other examples using its different options presented to you in its help manual.