0

Like in Windows OS, I look for a way to see how much data has been used since I connected to a Wi-Fi network. I only came accross with vnstat, however, either it cannot provide what I want, or I could not manage to do it.

My desired operation:

I connected to a wi-fi at 1:00 pm let's say. Then at 2:00 pm, I wanted to see how much data I have used so far. What should I do?

Thanks.

p.s : Ubuntu 20.04

muyustan
  • 268

1 Answers1

1

There are multiple options for that:

1) you can refer to the output of ifconfig <name_of_your_interface>:

$ /sbin/ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet [redacted]  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 [redacted]  prefixlen 64  scopeid 0x20<link>
        ether [redacted]  txqueuelen 1000  (Ethernet)
        RX packets 2911989  bytes 3104700566 (2.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1741814  bytes 307260264 (293.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In the RX bytes line, you have the number of received bytes

        RX packets 2911989  bytes 3104700566 (2.8 GiB)

In the TX bytes line, you have the number of sent bytes

        TX packets 1741814  bytes 307260264 (293.0 MiB)

2) Refer to How to get TX/RX bytes without ifconfig?:

cat /proc/net/dev

3) You can use netstat -i (columns RX-OK and TX-OK)

4) ip -s link

5) If you want a live usage, you can use iftop (may need to be installed with apt, needs root privileges)

Musinux
  • 136
  • 3
  • Thanks, all of them are nice, however, I think none of them is capable of providing exactly what I want. The closest is sudo iftop -i wlp2s0, however, it looks like I have to call it to start recording data usage by myself. I was looking for something constantly doing that in background and then I want to get the information when I want. Your 1st option for example, does this kind of a thing but the problem with it is that it records all the past(I assume) not the current session. – muyustan May 24 '20 at 11:35
  • Indeed, I was not able to find a proper solution, but found how to reset the RX/TX counters https://askubuntu.com/a/348043/1085382 (really impractical IMHO) Otherwise, you can use a mix of nmcli which tells you the current wifi endpoint you are connected to, and vnstat which monitors the network usage – Musinux May 24 '20 at 11:52