UUID — Universally Unique Identifiers

UUID generation, parsing, and practical usage — fstab, NetworkManager, systemd, APIs, and RFC 9562.

UUID Fundamentals

UUIDs (Universally Unique Identifiers) are 128-bit identifiers defined by RFC 9562 (supersedes RFC 4122). They provide globally unique identity without a central authority.

Format

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
                │    │
                │    └── N = variant (8, 9, a, b = RFC 9562)
                └────── M = version (1-8)

Versions

Version Name How it works

v1

Time-based

Timestamp (100ns since 1582-10-15) + clock sequence + node (MAC address). Deterministic — same input = same UUID. Embeds creation time.

v3

Name-based (MD5)

MD5 hash of namespace UUID + name. Deterministic — same input = same UUID.

v4

Random

122 random bits. Most common. No embedded metadata. Used by NetworkManager, systemd, most applications.

v5

Name-based (SHA-1)

SHA-1 hash of namespace UUID + name. Deterministic. Preferred over v3 (stronger hash).

v7

Unix epoch time + random

Millisecond-precision timestamp + random. Sortable by creation time. RFC 9562 addition.


Generating UUIDs

Generate random UUID (v4)
uuidgen
Generate time-based UUID (v1 — embeds timestamp + MAC)
uuidgen --time
Generate SHA-1 name-based UUID (v5 — deterministic)
uuidgen --sha1 --namespace @dns --name "modestus-p16g.inside.domusdigitalis.dev"
Generate multiple UUIDs
for i in {1..5}; do uuidgen; done

Parsing UUIDs

Parse a single UUID — shows version, variant, timestamp (if v1)
uuidparse aff1a8ee-e3dc-4af1-8db4-2169a595a8b8
Parse multiple UUIDs from stdin
echo -e "aff1a8ee-e3dc-4af1-8db4-2169a595a8b8\n056a2880-5821-465f-adb2-90c32de0b06f" | uuidparse

UUIDs in Linux Systems

NetworkManager — connection identity survives renames

List all connection UUIDs
nmcli -t -f NAME,UUID c s
Parse all NM connection UUIDs with xargs
nmcli -t -f UUID c s | xargs uuidparse
Activate a connection by UUID (name-independent)
nmcli connection up uuid aff1a8ee-e3dc-4af1-8db4-2169a595a8b8

Block devices — fstab and crypttab

Show filesystem UUIDs (used in fstab)
lsblk -f -o NAME,UUID,FSTYPE,MOUNTPOINT
Show partition UUIDs (GPT PARTUUID)
blkid -s UUID -s PARTUUID /dev/nvme0n1p*
Find device by UUID
findfs UUID=4de1f373-f999-4e5b-ae62-8fe85cdd2f17
List all UUID symlinks
ls -la /dev/disk/by-uuid/

systemd — unit instance and invocation IDs

Show current boot ID
cat /proc/sys/kernel/random/boot_id
Show machine ID (persistent across boots)
cat /etc/machine-id
Show systemd invocation ID for a service
systemctl show -p InvocationID NetworkManager.service

UUIDs in APIs — extracting with jq

Extract UUID from ISE policy set response
curl -s ... | jq -r '.response[] | select(.name == "Domus_8021X") | .id'
Extract UUID and use in a follow-up call (command substitution)
RULE_ID=$(curl -s ... | jq -r '.response[] | select(.rule.name == "Domus_Cert_Admin_P16g") | .rule.id')
echo "${RULE_ID}"
Parse API UUIDs to determine if time-based or random
curl -s ... | jq -r '.response[].id' | xargs uuidparse

UUID Comparison with xargs

xargs pipes multiple UUIDs into uuidparse for batch analysis.

Parse UUIDs from a file
cat uuids.txt | xargs uuidparse
Extract UUIDs from JSON and parse
nmcli -t -f UUID c s | xargs uuidparse
Find all v1 (time-based) UUIDs in a set
nmcli -t -f UUID c s | xargs uuidparse | awk '$2 == "time-based" {print $1}'
Combine with grep for filtering
nmcli -t -f UUID c s | xargs -I {} sh -c 'uuidparse {} | grep -q "random" && echo "{} is random"'

Reference

Resource Description

man uuid

libuuid library — UUID generation and parsing

man uuidgen

Generate UUIDs from the command line

man uuidparse

Parse and classify UUIDs (version, variant, time)

RFC 9562

UUIDs — current standard (May 2024, supersedes RFC 4122)

RFC 4122

Original UUID specification (2005, now historic)