Bandwhich, previously known as What, is a command line, open source utility to display network bandwidth utilization by process, connection and remote IP or hostname. It sniffs the given network interface card and records IP packet size and finally cross reference it with the /proc filesystem on your Linux system or lsof command on Mac OS. It is written in Rust programming language and supports Linux and Mac OS.
$ yay -S bandwhich
Using Nix package manager:
$ nix-env -iA nixpkgs.bandwhich
On other Linux distributions, you can install it using Cargo package manager.
To use Cargo package manager, you need to install Rust programming language as described in the link given below.
After installing Rust, install Bandwhich using command:
$ cargo install bandwhich
The above command will install bandwhich to ~/.cargo/bin/bandwhich. So you need to type the full path each time to run bandwhich as shown below.
$ sudo ~/.cargo/bin/bandwhich
To fix this, just move the bandwhich binary to your $PATH (E.g. /usr/local/bin/) by creating symbolic link like below.
$ sudo ln -s ~/.cargo/bin/bandwhich /usr/local/bin/
Now, you can simply run bandwhich using command:
$ sudo bandwhich
Please be mindful that since bandwhich sniffs network packets, it requires root privileges. So you must run it with sudo prefix.
You might be encountered with the following error when installing Bandwhich using Cargo.
Updating crates.io index Installing bandwhich v0.6.0 Compiling libc v0.2.66 error: linker `cc` not found | = note: No such file or directory (os error 2) [...]
To fix this error, try the following solution.
Display Network Bandwidth Utilization Using Bandwhich Tool
To display the current bandwidth utilization by process, connection, IP or hostname, run:
$ sudo bandwhich
Sample output from my Ubuntu 18.04 LTS desktop:
To stop, press Ctrl+c.
By default, Bandwhich will display the network utilization from all network interfaces. If you want Bandwhich to listen on a particular network card, for example wlp9s0, use -i flag.
$ sudo bandwhich -i wlp9s0
$ bandwhich --help bandwhich 0.6.0 USAGE: bandwhich [FLAGS] [OPTIONS] FLAGS: -h, --help Prints help information -n, --no-resolve Do not attempt to resolve IPs to their hostnames -r, --raw Machine friendlier output -V, --version Prints version information OPTIONS: -i, --interface <interface> The network interface to listen on, eg. eth0
Hope this helps.