UUID (Universally Unique identifier) is a 128-bit unique number standardized by the Open Software Foundation. This number is universally unique and really impossible for a user to guess.
This tutorial shows how to generate UUID in Linux using uuidgen command line utility tool.
Generate UUID in Linux
Most of the Linux/Unix system supports the command line utility tool uuidgen to generate the UUID. If the package is unavailable install using apt install uuid-runtime
command.
Uuidgen can generate random-based, time-based and hash-based UUIDs. Random based UUIDs is sufficient in most cases.
Simply executing uuidgen generates a random UUID.
You can use the -t flag along with uuidgen to generate a UUID based on system time. In the same way uuidgen command with option -r generates the random UUID based mostly on random bits.
The followings are some examples to generate UUIDs.
To create a random UUID, use the following command:
uuidgen
Output
9c79364e-99e1-42a8-ada1-86c31ad1fa76
To generate time based UUID, run:
uuidgen -t
Use the command uuidgen with the option -r to generate random UUID.
uuidgen -r
To generate hash based UUID use --md5 or --shal with --namespace <namespace>.
Conclusion
In this tutorial, we learned how to generate UUID in Linux. Finding UUID in Linux pretty easy, which is commonly required when it comes to mount storage devices in fstab file.
Comments