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 [options]

PARAMETERS

-r
    Generate a random UUID (version 4).

-t
    Generate a time-based UUID (version 1).

-n -N
    Generate a name-based UUID (version 3 or 5 depending on command line or default). Use the options to provide and which are necessary to generate the UUID.

-v
    Specify the UUID version to generate (1, 3, 4 or 5). If not specified, version 4 is generated by default.

-h
    Display help and exit.

DESCRIPTION

The uuidgen command is a utility that generates universally unique identifiers (UUIDs), also known as globally unique identifiers (GUIDs). These identifiers are 128-bit numbers that are virtually guaranteed to be unique across time and space. This makes them useful for various purposes, including database keys, component identifiers, and software tagging. uuidgen supports generating UUIDs in several standard versions, most commonly versions 1, 3, 4, and 5.

By default, uuidgen generates a version 4 UUID, which is based entirely on random numbers. It can also generate other versions based on time stamps and other sources to increase uniqueness and decrease collisions. The command provides a simple and effective way to create unique identifiers within shell scripts and other automation tools.

uuidgen outputs the generated UUID to standard output, and the format of the output is a string of hexadecimal digits separated by hyphens.

CAVEATS

The uniqueness of UUIDs depends on the quality of the random number generator and the implementation of the specific version being used. For version 1 UUIDs, the accuracy of the system clock is also relevant.

OUTPUT FORMAT

The generated UUID is output in the standard RFC 4122 format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where each x represents a hexadecimal digit.

HISTORY

uuidgen is part of the libuuid library which is part of the util-linux package. uuidgen was originally part of the e2fsprogs package, but was later moved to util-linux.

UUIDs and GUIDs became more important with the spread of distributed systems and the need for unique identifiers for objects across different systems and networks. As the need grew, the command was refined to allow for the generation of different versions of UUIDs, each tailored to specific use cases.

SEE ALSO

lsblk(8)

Copied to clipboard