Is there a way to generate uuid in shell script, similar to $RANDOM, can i use $uuidgen to get a uuid, or do i need to install any package to generate a uuid in shell script
#!/bin/bash
echo $RANDOM
echo $uuid
You can find the UUID of all the disk partitions on your Linux system with the blkid command. The blkid command is available by default on most modern Linux distributions. As you can see, the filesystems that has UUID are displayed. A lot of loop devices are also listed.
Description. uuidgen, by default, generates a Universal Unique Identifier (UUID) on the standard output. The UUID is used to uniquely identifier an IDL interface definition.
No, a UUID can't be guaranteed to be unique. A UUID is just a 128-bit random number. When my computer generates a UUID, there's no practical way it can prevent your computer or any other device in the universe from generating that same UUID at some time in the future.
Have you tried
uuidgen
It's installed out-of-the-box on freeBSD systems like MacOS.
On Fedora, CentOS, and RHEL, get it from the util-linux
package (CentOS6 has it in util-linux-ng
). On debian, get it with sudo apt-get install uuid-runtime
. On other linux systems, try looking for the e2fsprogs
package.
From this rather comprehensive article.
http://0pointer.de/blog/projects/ids.html
(btw, that's the blog of Lennart Poettering)
Linux offers a kernel interface to generate UUIDs on demand, by reading from /proc/sys/kernel/random/uuid
This is a very simple interface to generate UUIDs. That said, the logic behind UUIDs is unnecessarily complex and often it is a better choice to simply read 16 bytes or so from /dev/urandom
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With