I know that I can use

cat /sys/class/net/eth0/statistics/rx_bytes

to 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 denied

Is 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 error

Warning: cannot open /proc/net/dev (No such file or directory). Limited output.
  • once use ip a or ip link with normal user. – PersianGulf Oct 4 '14 at 12:15
  • What distribution are you using, with what kernel version? Are you using a security framework such as SELinux? On Debian stable, this file is world-readable. Which directories are not world-readable on that path? – Gilles Oct 4 '14 at 12:50

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
  • Hey, I tried to copy your example line and exchanged the somegroup by my group and it told me, there is a syntax error. But thanks for the Idea, i finally did it this way, and it worked fine somegroup ALL=(ALL) NOPASSWD: /bin/cat /sys/class/net/eth0/statistics/rx_bytes somegroup ALL=(ALL) NOPASSWD: /bin/cat /sys/class/net/eth0/statistics/tx_bytes – Racer Oct 4 '14 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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