I am trying to get a unique system identifier. During research I stumbled on the
system serial number which is exactly what I need (also present on the computer case).
The serial number is written in the file located in sysfs:
ls shows that the file is read protected and owned by root:
-r-------- 1 root root 4096 Mai 29 16:00 product_serial
I can't therefore write to it (which is perfect) and I also can't read it without
sudo which my program cannot be executed under.
If I change the ownership of this file to my user (which is in sudo group), then I can read it also with my program without using sudo. But this is overwritten with each reboot.
My question is: can reading of this file (serial number) be done without using
sudo? Is there perhaps another way to get the serial number that I'm missing?
Is there perhaps a
udev rules that could change the ownership? I have seen that
hal existed and did exactly what I'd like, but support what dropped in favor of
udev. I also thought about reading the information with
sudo at system startup and saving it somewhere else, but this way the file would then be changeable... Also there is
dmidecode but also needs
sudo for accessing this file..