uuidgen utility creates a new Universal Unique Identifier (UUID) and print it to standard output. The generated UUID consists of five hyphen-separated groups of hex digits (e.g., 3cdfc61d-87d3-41b5-ba50-32870b33dc67). The default is to generate a random-based UUID, but this requires that a high-quality random-number generator be available on the system.
In case you encounter the below error:
uuidgen: command not found
you may need to install the below package as per your choice of distribution.
Distribution | Command |
---|---|
OS X | brew install e2fsprogs |
Debian | apt-get install uuid-runtime |
Ubuntu | apt-get install uuid-runtime |
Alpine | apk add util-linux |
Arch Linux | pacman -S util-linux |
Kali Linux | apt-get install uuid-runtime |
CentOS | yum install util-linux |
Fedora | dnf install util-linux |
Raspbian | apt-get install uuid-runtime |
Docker | docker run cmd.cat/uuidgen uuidgen |
Examples of uuidgen command
1. Create a UUID based on the current time:
# uuidgen --time
2. Create a UUID based on the hash of a URL:
# uuidgen --sha1 --namespace @url --name object_name
Sample outut from uuidgen command:
# uuidgen a6333e94-0608-4abf-ba82-b0f0f13ef986