How to Get the UUID of a Disk Partition in Linux

UUID (Universally Unique Identifiers) is a property of disk partitions and is crucial while managing servers with hundreds of drives.

And the easiest way to get UUID is to list the contents of /dev/disk/by-UUID using the ls command:

ls -l /dev/disk/by-uuid/

The highlighted text in light blue color is the UUID of the partition highlighted with yellow color.

That's just one way to know the UUID of a partition. There are couple of more ways as well.

Using the blkid utility to get UUID

The blkid utility is used to get information about data blocks in Linux.

And when used without any options, you get details, including the UUID of every memory block present in the system:

blkid
Click to enlarge

And if you want to get the UUID of a specific block, just specify the block name as shown:

blkid /dev/sda2
Click to enlarge

Using the lsblk utility to get UUID

The lsblk utility is mainly used to list block devices but when used with the -f option, it can get you additional info, including the UUID of every block:

lsblk -f

And if you are on Ubuntu or your system is loaded with snap packages, they will be listed here too. In that case, you can filter those results using the grep command:

lsblk -f | grep -v loop

Wrapping Up

Through this tutorial, I explained how you could get the UUID of a disk partition in Linux. And if you have any other questions, feel free to let me know in the comments.