Skip to content

Instantly share code, notes, and snippets.

@Happyholic1203
Forked from bencord0/system_uuid.sh
Created March 9, 2018 08:51
Show Gist options
  • Save Happyholic1203/0705198e2a288d0663d43709fa0b3816 to your computer and use it in GitHub Desktop.
Save Happyholic1203/0705198e2a288d0663d43709fa0b3816 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