How to get dmidecode information without root privileges?
Some of the information presented by dmidecode
is available at /sys/devices/virtual/dmi/id
.
Other information can be obtained by analysing /proc/cpuinfo
, /proc/meminfo
or /sys/system/node/node0/meminfo
.
I can read DMI information as User under
/sys/class/dmi/id/
. Not including serial numbers (which require root privileges to read).I guess this is intended behavior by privacy aware kernel developers.
Regarding
dmesg
:dmesg
is a command for accessing the kernel ring buffer. Ring buffer implies older information are overwritten by newer ones when the buffer is "overflowing". Also this is reading kernel module debug output which was never meant to be parseable.To access kernel output with
systemd
run:journalctl --quiet --system --boot SYSLOG_IDENTIFIER=kernel
Regarding david-homer's and nils' answers: The file
/dev/mem
does not simply give memory information, but maps the whole physical memory into the userspace. Therefore one can access DMI memory addresses through it (and do much more nasty things).Regarding
chgrp
andchmod g+s
ofdmidecode
in nils' answer: I guess this won't work as intended, because saving gid withchmod g+s
doesn't makedmidecode
use it's new privileges.dmidecode
has to callsetegid
to set it's effective group id before it can access/dev/mem
. Judging from it's source code,dmidecode
doesn't do that.
I just checked on my CentOS 5 system - after:
chgrp kmem /usr/sbin/dmidecode
chmod g+s /usr/sbin/dmidecode
It is still not possible to get dmidecode working - the group kmem has only read-rights for /dev/mem - it seems there is a write involved to get to the BIOS information.
So some other options:
- Use sudo
- Use other information sources (e.g. /proc/meminfo )
- Use an init-script that writes the static output of dmidecode to a world-readable file