Open In App

iftop command in Linux with Examples

Last Updated : 31 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

iftop is a network analyzing tool used by system administrators to view bandwidth-related stats. It shows a quick overview of the networking activities on an interface. It stands for Interface TOP and the top is derived from the op command in Linux. It even acts as a diagnostic to diagnose which program is causing the problem to the network.

Installing iftop command

For RedHat-based Linux (version 8 or below)

yum install epel-release
yum install  iftop

For RedHat-based Linux (version 9)

sudo dnf install epel-release
sudo dnf install iftop

For Debian or Ubuntu Linux

sudo apt install iftop

Options available in `iftop` command in Linux

Options

Description

iftop

Displays basic real-time bandwidth usage of the default network interface.

-i wlo1

Shows real-time bandwidth details of a specific network interface named “wlo1”.

-n -i wlo1

Disables hostname lookup and provides bandwidth statistics for the specified interface “wlo1”.

-N -i wlo1

Disables the conversion of port numbers to services and presents bandwidth stats for the specified interface “wlo1”.

-b

Turns off the display of the bar graph representation for network traffic.

-t

Presents the output in a text interface format without using ncurses.

-o source

Sorts the output based on the source IP address of network flows.

-o destination

Sorts the output based on the destination IP address of network flows.

-L 2 -i wlo1

Specifies that only 2 lines of statistics or bandwidth usage should be printed for the interface “wlo1”.

-h

Displays the help section providing usage information and options for the iftop command.

Working with iftop Command

1. To display basic bandwidth usage of the default interface.

iftop
Display Basic bandwidth usage

Display Basic bandwidth usage

This command will now display all the bandwidth related stats of the default interface.

2. To display bandwidth details of a specific router

sudo iftop -i wlo1
display bandwidth deatil

display bandwidth deatil

This command will now display all the bandwidth related stats of the specified network interface which is wlo1.

3. To stop hostname lookup

sudo iftop -n -i wlo
To stop hostname lookup

To stop hostname lookup

This command will now stop the lookup of the hostname for the specified network interface which is wlo1.

4. To stop the conversion of port numbers to services.

sudo iftop -N -i wlo1
stop the conversion

stop the conversion

This command will not convert the port number to services while printing stats for the specified network interface which is wlo1.

5 To stop the display of bar graph.

sudo iftop -b
Display a bar graph

Display a bar graph

This command will remove the bar graph of traffic from the output.

6. To display the text interface without ncurses

sudo iftop -t
Display without ncurses

Display without ncurses

This command will display the output in the text interface without ncurses.

7. To sort output by source address

sudo iftop -o source 
To sort by source

To sort by source

This command will sort the output on the basis of the source address.

8. To sort output by destination address

sudo iftop -o destination
To sort by destination

To sort by destination

This command will sort the output on the basis of the destination address.

9. To specify number of lines to be printed

sudo iftop -L 2 -i wlo1
To display specific number

To display specific number

This command will print 2 output lines of statistics or bandwidth usage and not more than 2 lines will be printed.

10. To display help

sudo iftop -h
help

help

This command will display the help section of the iftop command.

Conclusion

In this article we discussed ‘iftop’ command which is a valuable network analysis tool for administrators, providing real-time bandwidth usage stats and aiding in network troubleshooting. With customizable options, it offers efficient monitoring and sorting capabilities. By installing ‘iftop’ on Linux distributions, administrators can gain insights into network traffic and optimize network performance effectively.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads