Skip to content

Instantly share code, notes, and snippets.

@alice-xu
Created July 1, 2014 04:01
Show Gist options
  • Save alice-xu/ad8b4ad8c9a85135d6c3 to your computer and use it in GitHub Desktop.
Save alice-xu/ad8b4ad8c9a85135d6c3 to your computer and use it in GitHub Desktop.
Get system uuid on Virtual Machine
#!/usr/bin/env bash
SYSTEM_UUID=$( cat /sys/devices/virtual/dmi/id/product_uuid 2> /dev/null | tr 'A-Z' 'a-z' \
|| cat /sys/hypervisor/uuid 2> /dev/null | tr 'A-Z' 'a-z' )
[ -z "${SYSTEM_UUID}" ] && SYSTEM_UUID='00000000-0000-0000-0000-000000000000'
echo ${SYSTEM_UUID}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment