Simple way of getting bandwidth usage using the Terminal

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
ChrisUK
Posts: 299
Joined: Tue Dec 12, 2017 12:04 pm

Simple way of getting bandwidth usage using the Terminal

#1 Post by ChrisUK »

This might help someone:

Nowadays, most seem to have uncapped bandwidth - for those that don't: vnstat is the perfect tool to monitor what you've downloaded/uploaded each day. For those that don't need or want a daemon running, you can just run a command in the terminal.

You could run

Code: Select all

ifconfig
which will give you details of all interfaces, including downloaded/uploaded bytes per interface. If you wanted to log those bytes, you'd probably need to use awk and/or sed to filter the information gained from ifconfig. But if you just wanted a single line to type in the terminal (or use in a script for logging purposes... replacing cat with echo) that will give you the formatted bytes downloaded since boot, you could type the following (assuming wlan0 is the interface)

Code: Select all

cat /sys/class/net/wlan0/statistics/rx_bytes | numfmt --to iec --format "%8.4f"
If you have a look in /sys/class/net/<YOUR_NETWORK_INTERFACE>/statistics/ (replacing <YOUR_NETWORK_INTERFACE> with eth0 or wlan0 etc) - you'll see there's a lot of info monitored/stored (bytes/packets/errors etc) - so it would be easy to get further info (eg. just change rx_bytes to tx_bytes in the above one-liner to get bytes uploaded)
Chris

MX 18 MX 19 - Manjaro

User avatar
oops
Posts: 1878
Joined: Tue Apr 10, 2018 5:07 pm

Re: Simple way of getting bandwidth usage using the Terminal

#2 Post by oops »

Thank you, can be useful
or.

Code: Select all

cat /sys/class/net/*/statistics/rx_bytes | numfmt --to iec --format "%8.4f"

# * for:
# ls /sys/class/net/
# eth0/  lo/    wlan0/ 
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

Post Reply

Return to “Tips & Tricks by users”