Nov 26, 2022 2 min read

How to Get the UUID of a Disk Partition in Linux

Table of Contents

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/
use ls command to get UUID of partitions in linux

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 command output
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
get UUID of a specific block in Linux
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
use lsbk command to get UUID of disk in Linux

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.

Sagar Sharma
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Linux Handbook.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.