Universally Unique Identifier UUID with uuidgen

Are you trying to generate a Universally Unique Identifier (UUID) with uuidgen?

This guide is for you.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Linux related Tasks.

In this context, we shall learn you the process to generate Universally Unique Identifiers (UUIDs).

More information about a universally unique identifier (UUID)?

Universally unique identifiers (UUIDs) are 128-bit numbers that are unique and are used to identify information in computer systems.

They are composed of 16 octets and represent 32 base-16 characters.

Moreover, the central authority does not issue it instead you can generate it independently and then use it across a given system without suspicion of duplicate.

How to generate a Universally Unique Identifier (UUID) with uuidgen?

This steps will show you the steps to generate UUIDs.

1. Generating a UUID

Often, the uuidgen command is already installed on Unix OS systems like Linux and macOS. In case, if it is not then you can install it through the package manager. On Ubuntu and Debian systems, run the below command to install the UUID-runtime package.

$ sudo apt install uuid-runtime

Here is the command to generate a single UUID that has no arguments.

$ uuidgen

2. How to generate Multiple UUID?

In order to generate multiple UUIDs, you would need to make use of shell scripting. You can use the for loop to execute the uuidgen command multiple times.

For instance, run the following command to generate 10 UUIDs.

$ for i in {1..10}; do uuidgen; done

As a result, you must see 10 UUIDs printed to the screen.

3. How to use UUID in Test Data?

If you wish to generate a list of 2 UUIDs per line that is comma-separated values (CSV), you would need to use the echo command to print two UUIDs during each iteration of the for a loop. For that, run the below command.

$ for i in {1..10}; do echo `uuidgen`,`uuidgen`; done

Also, you can generate data that looks like an email address by making a small tweak to the echo statement.

$ for i in {1..10}; do echo `uuidgen`@`uuidgen`.com; done

The output would be as below;


However, the output won’t be a real email address, but you can tweak the output one more time, and swap the second uuidgen for a disposable email address domain. These won’t be a list of realistic-looking data, but it will be a list of the email addresses you could actually use or monitor in tests.

Here is the command for it;

$ for i in {1..10}; do echo `uuidgen`@mail.com; done

This time, the output would be as below;


Then to save this output to a file, append > /path/to/some/file to pipe the output.

$ for i in {1..10}; do echo `uuidgen`@mailinator.com; done > /tmp/emails.txt

Then you can use the cat command to view the file you just created.

$ cat /tmp/emails.txt

[Need urgent assistance with Linux related Installation and tasks? – We are here to help you.]


This tutorial will guide you the steps to generate Universally Unique Identifiers (UUIDs) with uuidgen.

For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com