Best of Linux

How to Install and Use UUIDgen in Debian 12

How to Install and Use UUIDgen in Debian 12

Debian is an operating system that provides multiple packages such as “dbus-bin”, “uuid-runtime”, etc. to perform different tasks. UUID is an abbreviation for Universally Unique Identifiers. UUIDs are quite powerful and can be used to create useful data on the command line interface with shell scripting.

This article will demonstrate the installation and usage of UUIDgen in Debian 12.

What is UUIDgen?

To create Universally Unique Identifiers, we use a tool known as UUIDgen. UUIDgen is a convenient tool for programmers and administrators. It helps to identify our resources uniquely. The UUIDgen tool generates a new universally unique identifier with the help of the “libuuid library”.

How to Install UUIDgen in Debian 12?

To install the UUID runtime package, simply use the command given below:

$ sudo apt install uuid-runtime

After installing the “uuid-runtime” package, a single UUID user can be generated using the following command:

$ uuidgen

The following output will be displayed with a different UUID:

To create time-based UUIDs, use the “uuidgen -t” command as shown below:

$ uuidgen -t

To generate a random UUID use “-r” along with “uuidgen” using the command:

$ uuidgen -r

How to Generate Multiple UUIDs?

To create a list of UUIDs at once, we will shell scripting using a for loop. To retrieve a list of 10 UUIDs use the command:

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

We can see that 10 UUIDs are displayed on the screen as shown below:

How to Use UUIDs in Test Data?

To display a list of comma-separated values (CSV) along with Two UUIDs per line, we use the echo command with a “for loop”. Execute the command shown below:

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

This will create a CSV with two UUIDs per line:

Similarly, we can create data with email addresses by using the following command:

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

These aren’t real email addresses, but we can change the above command a bit and replace the second uuidgen with an email address domain like “junkfilter.com” as shown below:

 

Conclusion

UUIDs are quite powerful. To install UUID in Debian 12, use the “sudo apt install uuid-runtime” command. To generate a single user use the “UUIDgen” command. We can create hash-based and time-based UUIDs using the “uuidgen -t” and “uuidgen -r” commands. We can also create data like email addresses using the “for i in {1..10}; do echo `uuidgen`, `uuidgen`; done” command. This write-up has depicted how to install and use UUIDgen in Debian 12.

Similar Posts