LinuxCommandLibrary

uuidgen

Generate a unique UUID

TLDR

Create a random UUIDv4

$ uuidgen [[-r|--random]]
copy

Create a UUIDv1 based on the current time
$ uuidgen [[-t|--time]]
copy

Create a UUIDv5 of the name with a specified namespace prefix
$ uuidgen [[-s|--sha1]] [[-n|--namespace]] [@dns|@url|@oid|@x500] [[-N|--name]] [object_name]
copy

SYNOPSIS

uuidgen [OPTION]...

PARAMETERS

-r, --random
    Generates a random-based UUID (Version 4). This is the default behavior if no option is specified. The UUID is generated using a cryptographically strong pseudorandom number generator.

-t, --time
    Generates a time-based UUID (Version 1). This UUID incorporates the current timestamp and the MAC address of a network interface. It is guaranteed to be unique for a given system but may reveal system-specific information.

-v, --version
    Displays version information for the uuidgen command and exits.

-h, --help
    Displays a help message with usage information and exits.

DESCRIPTION

uuidgen is a command-line utility used to generate a 128-bit number that is globally unique. These numbers, known as Universally Unique Identifiers (UUIDs) or Globally Unique Identifiers (GUIDs), are designed to be unique across all space and time, minimizing the chance of collisions, even without a central coordination authority.

By default, uuidgen generates a Version 4 (random) UUID, which relies on a high-quality pseudorandom number generator for its uniqueness. This version is generally preferred for its simplicity and privacy benefits, as it contains no identifying information. Alternatively, it can generate a Version 1 (time-based) UUID using the system's current timestamp and the MAC address of a network interface card. Version 1 UUIDs are guaranteed to be unique if generated on a system with a unique MAC address and correctly synchronized clock, but they can raise privacy concerns due to the embedded MAC address.

UUIDs are widely used in various computing contexts, including databases, distributed systems, file systems, and configuration management, to uniquely identify records, objects, or entities without requiring a central registry. The output is a 36-character hexadecimal string, typically formatted with hyphens (e.g., xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx).

CAVEATS

When generating Version 1 (time-based) UUIDs, the MAC address of the host machine is embedded, which could potentially raise privacy concerns in certain contexts. For Version 4 (random-based) UUIDs, the quality of the generated UUID depends on the randomness source (/dev/urandom on Linux systems). While highly improbable, theoretical collisions are possible if the random number generator is compromised or if an astronomical number of UUIDs are generated.

UUID VERSIONS

uuidgen primarily supports two UUID versions:

Version 1 (Time-based): Incorporates the current timestamp and the MAC address of the generating machine. Ensures uniqueness over time and space, but reveals system information.

Version 4 (Random-based): Generated entirely from random numbers. Offers better privacy as it contains no identifying system information and is the default for uuidgen due to its simplicity and broad applicability.

OUTPUT FORMAT

The UUID produced by uuidgen is a 128-bit number represented as a 36-character string of hexadecimal digits (32 digits plus four hyphens), adhering to the standard format: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, where 'M' denotes the UUID version and 'N' indicates the variant. For example: a1b2c3d4-e5f6-4789-abcd-1234567890ab.

HISTORY

The concept of Universally Unique Identifiers originated from Apollo Network Computing System (NCS) and was later standardized by the Open Group's Distributed Computing Environment (DCE). The specific implementation of uuidgen is typically part of the util-linux project, a collection of essential Linux utilities. It adheres to RFC 4122, which defines the format and generation process for UUIDs. Its development has focused on providing a simple, reliable command-line interface to the underlying libuuid library, making UUID generation easily accessible for scripting and general use cases.

SEE ALSO

uuidd(8), libuuid(3)

Copied to clipboard