How to get TX/RX bytes without ifconfig?

Another option is to use the /proc filesystem. The /proc/net/dev file contains statistics about the configured network interfaces. Each line is dedicated to one network interface and it contains statistics for receive and transmit. The statistics include metrics such total number of received/transmittted bytes, packets, drops, errors and so on.

cat /proc/net/dev

    Inter-|   Receive                                                |  Transmit
     face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed

    lo:    29846937   129576     0    0    0     0          0       0 29846937   129576     0    0    0     0       0          0
 wlan0:    9467393340 8027251    0    0    0     0          0       0 2559312961 5896509    0    0    0     0       0          0

Or you can try the netstat command which can display all network interfaces and related statistics:

netstat -i

Iface   MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
lo         65536   0   130435      0      0      0   130435      0      0      0 LRU
wlan0       1492   0  8028018      0      0      0  5897361      0      0      0 BMRU

Leave a Comment