Simple way of getting bandwidth usage using the Terminal
Posted: Sun Sep 13, 2020 2:39 am
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 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)
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)
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
Code: Select all
cat /sys/class/net/wlan0/statistics/rx_bytes | numfmt --to iec --format "%8.4f"