0

On Windows and MacOSX it is trivial to retrieve some kind of UUID per machine:

On Windows (regedit):

"Software\Microsoft\Cryptography\MachineGuid"

On MacOSX

$ ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID

However on Linux this is much more complex. So far I have found the following:

  1. On dbus based system:

    $ cat /var/lib/dbus/machine-id

  2. On x86 based system (requires root power):

    $ sudo cat /sys/devices/virtual/dmi/id/product_uuid

  3. On PowerPC based system:

    $ cat /proc/device-tree/serial-number

What's really odd, is that UUID for the main board on x86-based arch is restricted to root user, but can be accessed using regular user via hal ($ lshal | grep 'system\.hardware\.serial'). While at the same time, all disk UUIDs can be accessed ($ ls /dev/disk/by-uuid/) and serial number can be accessed from any user on PowerPC-based arch.

So is there any portable UUID I can use on Linux ? dbus may or may not be installed, I need to read this value from a non-root user, and it needs to remains the same across reboot (/proc/sys/kernel/random/boot_id is therefore not an option).

malat
  • 11,097
  • 10
  • 70
  • 131
  • [Is there a UUID type of value in Linux that can uniquely identify an instance of a VM?](https://stackoverflow.com/q/8722050/608639), [Best way to get machine id on Linux?](https://stackoverflow.com/q/10152762/608639), [Generate consistent machine unique ID](https://unix.stackexchange.com/q/144812), etc. – jww Sep 06 '19 at 23:55

1 Answers1

1

Looks like systemd is now installed on most Linux distributions these days, therefore i can rely on /etc/machine-id being present and readable from a regular user.

malat
  • 11,097
  • 10
  • 70
  • 131