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.
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:
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.
To elaborate the answer from @flakeshake: files under
/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
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 ...