Universally unique identifiers (UUIDs) are 128-bit numbers that are accepted as being unique on the local system they are created on as well as among the UUIDs created on other systems in the past as well as the future. Because of their uniqueness, they come in handy in situations where an auto incremented primary key can fall short.
Because of their uniqueness, UUIDs are well suited for generating test data. Need a random string? A UUID is fine. What about an email?
[email protected]
is great. Need a bunch of random string? UUIDs will be unique, making them easy to track down as they move through a system.
To generate universally unique identifiers from the command-line interface, you can use the
uuidgen
utility,
In this tutorial you’ll use
uuidgen
and some shell scripting to generate UUIDs and some sample data.
The
uuidgen
command is often already installed on Unix-like operating systems like Linux and macOS. If it’s not, you can install it through your package manager. On Ubuntu and Debian systems, install the
uuid-runtime
package.
First, update your system’s list of available packages using the
apt update
command: