LinuxCommandLibrary

genid

Generate unique identifiers (UUIDs) for resources

TLDR

Generate a UUIDv4

$ genid uuid
copy


Generate a UUIDv5 using a namespace UUID and a specific name
$ genid uuidv5 [{ce598faa-8dd0-49ee-8525-9e24fff71dca]} [name]
copy


Generate a Discord Snowflake, without a trailing newline (useful in shell scripts)
$ genid --script snowflake
copy


Generate a Generic Anonymous ID with a specific "real ID"
$ genid gaid [real_id]
copy


Generate a Snowflake with the epoch set to a specific date
$ genid snowflake --epoch=[unix_epoch_time]
copy

SYNOPSIS

genid [OPTIONS...] [TYPE]

PARAMETERS

TYPE
    Specifies the type of ID to generate. Common types include uuid, machine, boot, host, etc. If omitted, a UUID is usually generated.

--uuid
    Generates a standard version 4 UUID.

--machine
    Generates a unique Machine ID, typically used for /etc/machine-id.

--boot
    Generates a unique Boot ID for the current system boot.

--host
    Generates a unique Host ID.

--from-name=NAME
    Generates a version 5 UUID from a specified string NAME, based on a namespace.

--namespace=ID
    Specifies a namespace ID (UUID) to be used with --from-name for deterministic ID generation.

--random
    Ensures the generated ID is cryptographically random.

--pretty
    Formats the output ID with hyphens (e.g., xxxxxxxx-xxxx-...). Default is typically raw hex.

--save-to=PATH
    Saves the generated ID to the specified file path.

--version
    Displays the version information and exits.

--help
    Displays a help message and exits.

DESCRIPTION

The genid command is a utility, typically part of the systemd-id128 package, used for generating different types of 128-bit unique identifiers. These IDs include Universally Unique Identifiers (UUIDs), Globally Unique Identifiers (GUIDs), Machine IDs, Boot IDs, and Host IDs.

These identifiers are fundamental to systemd's operation, ensuring unique identification for system components, boots, and installations. genid can produce IDs based on cryptographic randomness, derived from names, or from file contents. It's often employed by system administrators or scripts to initialize or re-generate specific system identifiers, such as the content of /etc/machine-id. The command ensures generated IDs conform to standard UUID formats (e.g., DCE 1.1, ISO/IEC 11578). While it can generate general-purpose UUIDs, its primary role is in low-level system identifier management rather than typical end-user application development.

CAVEATS

genid is often a symlink to systemd-id128. It's primarily a low-level utility for system-level ID management within systemd environments. Modifying critical system IDs like the Machine ID should be done with extreme caution, as it can impact system uniqueness and services depending on it. Elevated privileges are often required for such operations.

TYPES OF 128-BIT IDS

genid is capable of producing several distinct types of 128-bit unique identifiers:
UUID: A Universally Unique Identifier, typically a version 4 (random) or version 5 (name-based) identifier, used for general-purpose unique identification.
Machine ID: A unique ID for a specific host installation, usually stored in /etc/machine-id. It persists across reboots and is crucial for many systemd services and network identification.
Boot ID: A unique ID generated for each system boot. It changes every time the system starts up, used for distinguishing individual boot sessions.
Host ID: Another form of unique identifier for a host, distinct from the Machine ID, used in specific contexts.

HISTORY

The genid command, as part of systemd-id128, emerged with the development of the systemd init system, which gained prominence in the early 2010s. It was designed to provide standardized and robust mechanisms for generating and managing critical 128-bit unique identifiers required by systemd for various components and operations, replacing older, less centralized ID generation methods.

SEE ALSO

uuidgen(1), systemd-id128(1), machine-id(5), boot-id(5)

Copied to clipboard