UUID stands for Universally Unique Identifier. UUIDs are used as IDs (to identify) unique objects or records. An easy way to generate UUIDs in Linux is to use the uuidgen utility on the Linux/Unix command line.

Generating UUID with uuidgen

Simply executing uuidgen will generate a random UUID. Using the -t option will create a UUID based on system time and ethernet address if available. The -r option create a random UUID based mostly on random bits (this is the default). Below are examples of using all three:

#!/bin/bash

#create uuid (default same as using -r option)
$ uuidgen
b03108db-65f2-4d7c-b884-bb908d111400

#create time based uuid
$ uuidgen -t
30799dba-881f-11e6-84ae-024206e5b105

#create random uuid
$ uuidgen -r
a68eddcd-6eec-4b5e-846d-97b1161248e2

For more information about UUID variants, versions, etc. the Wikipedia UUID Page is a great resource. A higher level explanation of UUIDs can also be found in post What is a UUID?

Leave a Reply

How to Generate a UUID in Linux