A comprehensive guide to generating UUIDs on Linux using the uuidgen command. Covers all four UUID versions: Version 1 (time-based, encodes MAC address), Version 3 (MD5 namespace hash), Version 4 (random, default), and Version 5 (SHA-1 namespace hash). Explains installation on Debian/Ubuntu (uuid-runtime) and RHEL/Fedora (util-linux), practical shell scripting patterns including loops, command substitution, and filename generation. Also covers alternative methods like reading from /proc/sys/kernel/random/uuid and Python's uuid module. Includes a comparison table of all methods with RFC 4122 compliance notes and guidance on choosing the right UUID version for database keys, distributed systems, and idempotent operations.
Table of contents
IntroductionKey TakeawaysWhat Is a UUID?PrerequisitesInstalling uuidgen on LinuxGenerating a Basic UUID with uuidgenGenerating a Random UUID (Version 4)Generating a Time-Based UUID (Version 1)Generating Namespace-Based UUIDs (Version 3 and Version 5)UUID Version Comparison TableUsing uuidgen in Shell ScriptsAlternative Methods to Generate UUIDs on LinuxFrequently Asked QuestionsConclusionSort: