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
uuidgen
uuidgen --time
uuidgen --sha1 --namespace @dns --name "modestus-p16g.inside.domusdigitalis.dev"
for i in {1..5}; do uuidgen; done
Parsing UUIDs
uuidparse aff1a8ee-e3dc-4af1-8db4-2169a595a8b8
echo -e "aff1a8ee-e3dc-4af1-8db4-2169a595a8b8\n056a2880-5821-465f-adb2-90c32de0b06f" | uuidparse
UUIDs in Linux Systems
NetworkManager — connection identity survives renames
nmcli -t -f NAME,UUID c s
nmcli -t -f UUID c s | xargs uuidparse
nmcli connection up uuid aff1a8ee-e3dc-4af1-8db4-2169a595a8b8
Block devices — fstab and crypttab
lsblk -f -o NAME,UUID,FSTYPE,MOUNTPOINT
blkid -s UUID -s PARTUUID /dev/nvme0n1p*
findfs UUID=4de1f373-f999-4e5b-ae62-8fe85cdd2f17
ls -la /dev/disk/by-uuid/
systemd — unit instance and invocation IDs
cat /proc/sys/kernel/random/boot_id
cat /etc/machine-id
systemctl show -p InvocationID NetworkManager.service
UUIDs in APIs — extracting with jq
curl -s ... | jq -r '.response[] | select(.name == "Domus_8021X") | .id'
RULE_ID=$(curl -s ... | jq -r '.response[] | select(.rule.name == "Domus_Cert_Admin_P16g") | .rule.id')
echo "${RULE_ID}"
curl -s ... | jq -r '.response[].id' | xargs uuidparse
UUID Comparison with xargs
xargs pipes multiple UUIDs into uuidparse for batch analysis.
cat uuids.txt | xargs uuidparse
nmcli -t -f UUID c s | xargs uuidparse
nmcli -t -f UUID c s | xargs uuidparse | awk '$2 == "time-based" {print $1}'
nmcli -t -f UUID c s | xargs -I {} sh -c 'uuidparse {} | grep -q "random" && echo "{} is random"'
Reference
| Resource | Description |
|---|---|
|
libuuid library — UUID generation and parsing |
|
Generate UUIDs from the command line |
|
Parse and classify UUIDs (version, variant, time) |
UUIDs — current standard (May 2024, supersedes RFC 4122) |
|
Original UUID specification (2005, now historic) |