uuid
Generate universally unique identifiers (UUIDs)
TLDR
Generate a UUIDv1 (based on time and system's hardware address, if present)
Generate a UUIDv4 (based on random data)
Generate multiple UUIDv4 identifiers at once
Generate a UUIDv4 and specify the output format
Generate a UUIDv4 and write the output to a file
Generate a UUIDv5 (based on the supplied object name) with a specified namespace prefix
Decode a given UUID
SYNOPSIS
uuidgen
[options]
PARAMETERS
-r
Generate random UUIDs.
-t
Generate time-based UUIDs.
-n number
Generate number of UUIDs. If number isn't supplied, generates one UUID.
DESCRIPTION
The uuidgen
command creates new universally unique identifiers (UUIDs), also known as Globally Unique Identifiers (GUIDs). These identifiers are 128-bit values designed to be unique across space and time. UUIDs are often used as database keys, component identifiers in software systems, and for other situations where a unique identifier is required without central coordination. The generated UUIDs are based on the current system's hardware address and other information to ensure uniqueness. The command provides options to output the UUID in different formats, including hex representation with and without hyphens, and as a URI.
CAVEATS
While the probability of generating duplicate UUIDs is extremely low, it is not theoretically impossible. The -r
option generates purely random UUIDs, while -t
generates time-based UUIDs, which are dependent on the system's clock and MAC address. If the system clock is improperly set, or the MAC address is duplicated, the likelihood of collisions is increased.
OUTPUT FORMAT
The default output format is a 36-character string in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
, where x is a hexadecimal digit. You can pipe the output to other commands for further processing or storage.
RANDOM VS. TIME-BASED UUIDS
Random UUIDs (generated with -r
) rely on a cryptographically secure random number generator. Time-based UUIDs (generated with -t
) incorporate the current timestamp and the machine's MAC address. Random UUIDs are generally preferred for systems where privacy is a concern.
HISTORY
The uuidgen
command is part of the libuuid
library. libuuid
was designed to provide UUID generation functionality across different platforms and programming languages. It is widely used in many systems, including Linux and other Unix-like operating systems. The usage has grown significantly with the increase in distributed systems and the need for unique identification in databases and software architectures.