I know that I can use cat /sys/class/net/eth0/statistics/rx_bytesto see the amount of received bytes. Sadly I only can run this command as root.When I am another user, I get cat: /sys/class/net/eth0/statistics/rx_bytes: Permission deniedIs there an easy way to allow non-root users to read this file? Currently a non-root is not allowed to access any of the directories in path.I also tried to use ifconfig, but there I get this errorWarning: cannot open /proc/net/dev (No such file or directory). Limited output.
Allow non-root user go get network traffic statistics
networking;stat;sysfs
As far as I can tell, this file is public by default.Check if there are startup scripts that restrict permissions on your system, either with traditional file permissions or with a security framework such as SELinux or AppArmor.If you want to leave most directories opaque but allow access to this one file, you can add a sudo rule. To allow all users in somegroup to run the command sudo cat /sys/class/net/eth0/statistics/rx_bytes, run visudo and add a rule like%somegroup ALL = NOPASSWD: cat /sys/class/net/eth0/statistics/rx_bytes