Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to get machine id on Linux?

People also ask

What is machine ID in Linux?

The /etc/machine-id file contains the unique machine ID of the local system that is set during installation or boot. The machine ID is a single newline-terminated, hexadecimal, 32-character, lowercase ID. When decoded from hexadecimal, this corresponds to a 16-byte/128-bit value. This ID may not be all zeros.

How do I find my machine ID?

Click "PC Info" in the Settings menu. The System dialog box appears on the screen. Your machine ID appears to the right of Computer Name in the Computer Name, Domain and Workgroup Settings section.

How do I find my UUID BIOS Linux?

You can find the UUID of all the disk partitions on your Linux system with the blkid command. The blkid command is available by default on most modern Linux distributions. As you can see, the filesystems that has UUID are displayed.


Depending on your kernel, the DMI information may be available via sysfs. Try those:

# cat /sys/class/dmi/id/board_serial
xxxxxxxxxxxxxxx
# cat /sys/class/dmi/id/product_uuid
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

or using a tool

# dmidecode -s baseboard-serial-number
...
# dmidecode -s system-uuid
...

On modern machines with systemd: machine id is created by systemd-machine-id-setup. The location of machine id is documented - in freedesktop machine-id and man machine-id and machine id has a more standardized format - see RFC4122. Just:

cat /etc/machine-id

You can use lshal. This needs hal (apt-get install hal or yum install hal) to be installed first. This way you can access all the info of dmidecode without root permissions.

A non-root equivalent of

# dmidecode | grep -i uuid

will be

$ lshal |grep -i system.hardware.uuid

And similarly other info as per your needs.