LinuxCommandLibrary

uuid

Generate universally unique identifiers (UUIDs)

TLDR

Generate a UUIDv1 (based on time and system's hardware address, if present)

$ uuid
copy

Generate a UUIDv4 (based on random data)
$ uuid -v [4]
copy

Generate multiple UUIDv4 identifiers at once
$ uuid -v [4] -n [number_of_uuids]
copy

Generate a UUIDv4 and specify the output format
$ uuid -v [4] -F [BIN|STR|SIV]
copy

Generate a UUIDv4 and write the output to a file
$ uuid -v [4] -o [path/to/file]
copy

Generate a UUIDv5 (based on the supplied object name) with a specified namespace prefix
$ uuid -v [5] ns:[DNS|URL|OID|X500] [object_name]
copy

Decode a given UUID
$ uuid -d [uuid]
copy

SYNOPSIS

uuid [OPTION]...

PARAMETERS

-h, --help
    Display help information and exit.

-v, --version
    Output version information and exit.

-r, --random
    Generate a random (version 4) UUID. This is the default behavior.

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

-x, --hex
    Display the UUID in hexadecimal format. This is the default display mode.

-n, --name=name
    Generate a name-based UUID (version 3 or 5) from the provided name.

-N, --namespace=namespace
    Use the specified namespace for name-based UUID generation. The namespace itself must be a valid UUID.

DESCRIPTION

The uuid command is a utility for generating and displaying Universally Unique Identifiers (UUIDs).
A UUID is a 128-bit number used to uniquely identify information in computer systems. Its design ensures that each generated UUID is highly likely to be unique across time and space, even without a central coordinating authority.
The command primarily generates version 4 (random) UUIDs by default, leveraging the system's random number generator.
It also supports generating version 1 (time-based) UUIDs, which incorporate the current timestamp and the system's MAC address, and name-based UUIDs (versions 3 and 5) from a specific namespace and name.
UUIDs are widely used in various applications, including database primary keys, distributed computing systems, partition identifiers in Linux, and as unique identifiers for files or objects, providing a robust solution for ensuring global uniqueness.

CAVEATS

While UUIDs are designed for high uniqueness, it's important to note some caveats:
Random (version 4) UUIDs rely on a strong source of randomness (e.g., /dev/urandom). If the random source is compromised or weak, the uniqueness guarantee can be reduced.
Time-based (version 1) UUIDs can potentially expose the MAC address of the generating device and the timestamp of generation, which might be a privacy concern in some contexts.
Although extremely improbable, the possibility of a collision (two identical UUIDs being generated) exists for random UUIDs, as they are not guaranteed to be unique in a cryptographic sense.

<B>UUID</B> <I>VERSIONS</I>

RFC 4122 defines five versions of UUIDs:
Version 1: Time-based and MAC-address-based.
Version 2: DCE Security (rarely used).
Version 3: Name-based using MD5 hashing.
Version 4: Randomly generated.
Version 5: Name-based using SHA-1 hashing.
The uuid command primarily generates version 1, 3, 4, and 5.

<B>UUID</B> <I>FORMAT</I>

A UUID is represented as a 32-character hexadecimal string, displayed in five groups separated by hyphens, for a total of 36 characters (e.g., xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx).
The 'M' indicates the UUID version (e.g., '4' for random UUIDs).
The 'N' indicates the variant, which is typically '8', '9', 'a', or 'b' for RFC 4122 UUIDs.

HISTORY

The concept of UUIDs originated from the Apollo Network Computing System (NCS) in the 1980s and was later adopted by the Open Software Foundation's Distributed Computing Environment (DCE).
It was standardized by the Internet Engineering Task Force (IETF) as RFC 4122, which defines the format and mechanisms for generating five different versions of UUIDs.
The uuid command itself is typically part of the util-linux package on Linux systems, a collection of essential system utilities that have been developed and maintained over many years.

SEE ALSO

uuidgen(1), lsblk(8), mount(8), mkfs.ext4(8)

Copied to clipboard