Where are saved the information given by ifconfig command on raspbian?

I need to read these informations from a file.

Is there any file where (as an example) the mac address of an interface is stored?

  • Not specific to the Raspberry Pi. Why don't you just parse the output of the ifconfig command and extract the MAC?
    – joan
    Feb 14, 2018 at 16:12
  • Note that ifconfig has been considered obsolete for years on linux (see man ifconfig) and exists only for backward compatibility.
    – goldilocks
    Feb 15, 2018 at 13:52
  • @joan because i need to use a lot of scripts that involve the Mac addresses, I think is not handy parsing the output of ifconfig
    – clf maris
    Feb 20, 2018 at 7:58

1 Answer 1


Raspbian is a Linux based operating system and in Linux most information like the information provided by the ifconfig command is available in a special file. From this Superuser answer the MAC address is available by reading /sys/class/net/$iFACE/address where $iFACE is a shell variable that contains the interface name desired. Or just by explicitly reading file /sys/class/net/eth0/addresss for interface eth0.

raspberrypi ~ $ cat /sys/class/net/eth0/address
  • 1
    Worth noting that these are not files in a conventional sense of information serialized on disk somewhere (or serialized and stored at all). They do not exist when the system is not running. They are nodes created (mostly at boot) and maintained by the kernel; read requests on them are direct requests for information from the kernel, and write requests send information to the kernel. This goes back to the Unix "everything is a file" design principle.
    – goldilocks
    Feb 15, 2018 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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