Generating UUIDs of different versions in Linux Terminal
Generate
V4
To generate V4, simply run uuidgen:
uuidgen
output:
0c034caa-d26f-486a-96e4-28df9042fc8c
V5
To generate V5, specify namespace (e.g., @dns) and name (e.g., example.com) together with --sha1 flag:
uuidgen --sha1 --namespace @dns --name "example.com"
output:
cfbff0d1-9375-5685-968c-48ce8b15ae17
V7
As for V7, you can’t use uuidgen directly.
Parse
To parse a UUID and get its version and variant, use uuidparse:
uuidparse cfbff0d1-9375-5685-968c-48ce8b15ae17
output:
UUID VARIANT TYPE TIME
cfbff0d1-9375-5685-968c-48ce8b15ae17 DCE sha1-based
