In Linux, you can use the “uuidgen” tool to generate UUIDs. In this article, we will go over how to use the “uuidgen” tool to generate UUIDs.
What is a UUID
A UUID is a 128-bit value that is generated in a way that it is unique across all systems in the world. This means that you can use a UUID to identify resources without having to worry about conflicts with other systems. The UUID is typically represented as a string of 32 hexadecimal characters, separated into groups of 8, 4, 4, 4, and 12 characters.
Generating a UUID
Update the system’s list of available packages using the apt update command:
Now install the uuid-runtime package:
After the uuid-runtime package is install, we can generate a generate a single UUID by executing the following command in your terminal:
Following output will appear with a different UUID:
You can also generate time-based and hash-based UUIDs using the uuidgen command.
The below command will give time based UUID:
A random UUID can be obtained using the uuidgen with “-r”:
Generating Multiple UUIDs
To generate a list of UUIDs we can use a for loop.
Below command will generate 10 UUIDs randomly:
You’ll see 10 UUIDs printed to the screen:
To generate a custom number of UUIDs replace the value 10 with any number.
Conclusion
UUIDs are a convenient way of uniquely identifying resources in a globally unique manner. The “uuidgen” tool in Linux makes it easy to generate UUIDs, making it a useful tool for developers and system administrators. Whether you are working on a database, network interface, or other system, using UUIDs can help ensure that your resources are uniquely identified and accessible across multiple systems.