What is UUID (Universally Unique Identifier)?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-is-uuid-universally-unique-identifier/
PINTEREST
PINTEREST
INSTAGRAM

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.

Uniqueness

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.

Example UUID

Here are some UUID examples.

We can see that fstab content of the Linux systems contains UUID in order to indentify the disk partition.

Example UUID

Example UUID

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 UUID Based Host ID

Generate UUID Based Host ID

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.

LEARN MORE  How To Generate Random Numbers In Linux

Generate Fully Random UUID

Generate Fully Random UUID

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)