While developing applications or using services or mounting disks in Linux systems we may see the term UUID or 128 bit number which might seem interesting. UUID is 128 bir number which is used to identify things like name, record, disk whatever we want.
What makes UUID so special or interesting is its uniqueness. Yes it is right event two different and discrete systems creates UUID it is assumed both are unique and do not collide each other or with other UUID’s. Actually they are not perfectly unique but the probability of the collusion is very very very low to count.
Here are some UUID examples.
We can see that
fstab content of the Linux systems contains UUID in order to indentify the disk partition.
$ cat /etc/fstab
Generate UUID with Python
There are different ways to generate UUID. There is a lot of web based UUID generators but using Python is more attractive. We can use Python
uuid module to generate UUID with different options.
Generate UUID Based Host ID
While generating UUID we can make some part of UUID bound to the host. We will import
uuid module and run
uuid1() function in order to generate host based UUID.
Generate Fully Random UUID
If we need to generate completely random UUID we need to call
uuid4() function. Every time we call this function will create completely different UUID.