How to Generate UUIDs in Bash

Generate UUIDs in Bash with system tools such as uuidgen. Random v4 values are broadly available, while v7 depends on the installed utility version.

Recommendation: use uuidgen --random or equivalent tooling for UUID v4. Use UUID v7 only when your system tool explicitly supports it.

How to generate UUID v4 in Bash

uuidgen --random

How to generate UUID v7 in Bash

uuidgen --time-v7

This only works on systems where the installed uuidgen version supports UUID v7.

Native support notes

  • Bash does not have a built-in UUID generator.
  • Tool availability and flags differ across Linux distributions and macOS environments.
  • Document the exact system requirement if your scripts depend on UUID v7 support.

Practical notes

  • Prefer portable shell scripts when UUID generation is part of automation pipelines.
  • Fall back to application-layer generation if your shell environment is inconsistent.
  • See the validator if you need to confirm the generated UUID version.

Frequently Asked Questions

No. Bash normally delegates UUID generation to a system tool such as uuidgen.

No. UUID v7 support in uuidgen depends on the installed tool version and operating system packaging.

Learn more

These articles expand on related concepts, formats and practical considerations.

By using this site, you agree to our Privacy Policy and Terms of Service. You are not permitted to use the GUIDs (also known as UUIDs) generated by this site or use any other content, services and information available if you do not agree to these terms.
Disclaimer: All information is provided for general educational and technical reference only. While we aim to keep the content accurate, current and aligned with published standards, no guarantees are made regarding completeness, correctness or suitability for any specific use case.
GUID specifications, best practices, security guidance, database behavior and ecosystem conventions (including cloud platforms and identifier formats) may change over time or differ by implementation. Examples, recommendations and comparisons are illustrative and may not apply universally.
This content should not be considered legal, security, compliance or architectural advice. Before making critical design, security or production decisions, always consult the latest official standards and vendor-specific documentation.
Always evaluate behavior in your own environment.
Standards Compliance: The GUIDs generated by this site conform to RFC 4122 and RFC 9562 specifications whenever possible, using cryptographically secure random number generation.