Last active
August 31, 2023 11:51
-
-
Save bencord0/7690953 to your computer and use it in GitHub Desktop.
Unique id for a linux system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
What about
/etc/machine-id
?
When I wrote this, I don't think systemd was doing that much with machine-id, and the file didn't exist on my system
That isnt true any more.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about
/etc/machine-id
?