Is there a way you can query the model and revision of a Pi from a script without accessing files that are generated at install time for the OS? I have a project where a web page needs to display the model and revision of the Pi it is installed on, and I'm currently getting the info by looking at the revision number in /proc/cpuinfo. However, that file is populated when the OS is installed. The goal is to be able to have a single image that can be installed on either the Pi 2 or 3 and the page should be able to identify the model regardless of which Pi the image is installed onto.


2 Answers 2


Files inside /proc are not "installed".

/proc is a virtual filesystem. No files inside /proc exist on the SD Card.
They are created by Linux on every reboot and only exist inside RAM. Try the following command to get a model name, for example:

 cat /proc/device-tree/model

Linux itself will create, delete and modify files inside /proc to represent internals (id + memory addresses of processes, CPU cores, USB devices etc. etc.)

The files inside /proc will always be different even if all your Pis run the same image.

  • Huh... that's interesting. I've tried the same image on two different Pi's though and both said Pi 3 when one of them was a Pi 2, and I was grabbing from /proc/cpuinfo. I assumed since the image was made when that file already existed, then installing the image on another Pi would result in the same info in that file. Jan 16, 2019 at 17:46
  • @DarinBeaudreau Later model Pi2 use the same SOC as Pi3
    – Milliways
    Jan 16, 2019 at 21:07
  • Right, but the revision number is different for every model. That's what I was looking at. The problem was that I forgot to delete the page that was generated with the info already on it before creating the image. I just needed to delete it so it would re-create the file with the correct info on the page. Jan 16, 2019 at 21:44

To elaborate the answer from @flakeshake: files under /proc/ and /sys/ are called pseudo files. They are the interface from the kernel to the user space. The kernel shows its settings with them. So if looking at /proc/cpuinfo you get the info from the kernel it just see at the time you ask for it, e.g. with cat /proc/cpuinfo.

You can also modify the kernel settings by writing to pseudo files. For example look at network settings with ls -l /proc/sys/net/ipv4. Nearly all pseudo files there are writable so you can fine tune your network but you can also make it complete unusable ...

  • @DarinBeaudreau You can respect it by upvote ...
    – Ingo
    Jan 16, 2019 at 21:49
  • I did, but it's not visible because I only just joined this particular community. Jan 17, 2019 at 20:04

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.