Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use a 3G cellular Internet connection with a very strict traffic limit, but some times I go to office and use an unlimited and fast cable connection (and of course I do traffic-consuming operations, like updating the system there).

I'd like to keep track of how much have I already downloaded using the mobile connection (so, it can either filter by interface or be easily suspendable so that I can pause it when I use an unlimited line) this month (so, the counter most not reset when I reboot my laptop or reconnect, I'd lile to only reset it manually).

What's the easiest way to do this in Ubuntu 10.10?

I wouldn't like to set up any complex monitoring/billing systems.

share|improve this question

The simplest method

You can use ifconfig on you network interface (mine is eth0) - it counts the amount of data sent and received since the interface was started.

# Bytes Receive
ifconfig eth0 | awk '/RX bytes/ {print $2}' | awk -F: '{print $2}'

# Bytes Transmitted
ifconfig eth0 | awk '/RX bytes/ {print $6}' | awk -F: '{print $2}'

# A human readable output
ifconfig eth0 | awk '/RX bytes/ {print $3, $4}' # Received
ifconfig eth0 | awk '/RX bytes/ {print $7, $8}' # Transmitted

Making it persistent

Not so simple

share|improve this answer
I restart it frequently and would like a persistent counter. – Ivan Nov 2 '10 at 20:15

The Ubuntu community wiki lists instructions on using a couple of tools - ipac-ng and vnstat. They aren't necessarily simple, but they are better than writing your own scripts:

share|improve this answer

If you want a graphical way to track your network usage:


  • this screenlet (you will need screenlets (search for screenlets in software center or do sudo apt-get install screenlets in a terminal, then launch screenlets from (alt+f2) the run dialog, and click the install screenlet button when the config dialog comes up.
  • There is an applet for gnome-panel that does the same job (but sadly I do not remember the name). I will add that to my answer as soon as I find it (I'm searching for it). you may be able to find it under netmonitor I think

For each of these, you can choose which interface (eth0, wlan0, etc) to track from their preferences. You can also clear your totals every time you disconnect, so you know exactly how much you have used.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.