Skip to content

Instantly share code, notes, and snippets.

@ubogdan
Forked from bencord0/system_uuid.sh
Created July 11, 2018 21:14
Show Gist options
  • Save ubogdan/31a931f61f752fc35d25df177720b7c2 to your computer and use it in GitHub Desktop.
Save ubogdan/31a931f61f752fc35d25df177720b7c2 to your computer and use it in GitHub Desktop.
Unique id for a linux system
#!/bin/bash
cat /var/lib/dbus/machine-id && exit
# Provided by dbus, hence available on all systemd systems.
# Any user can read it and it is persistent accross boots.
# It is unique per installation, and works well in VMs.
# Not all systems (i.e. stage3 gentoo/handbook install)
# have dbus installed by default.
cat /sys/class/dmi/id/product_uuid && exit
# Which should be the same as
# dmidecode -s system-uuid
# Requires root
# Persistent accross re-installs
# Depends on x86 hardware
# Not available on all kernels, may be module dependent.
# Lennert Poettering has a good analysis
# http://0pointer.de/blog/projects/ids.html
# FreeBSD has
sysctl kern.hostuuid
# Which is persistent accross reboots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment