TL;DR
To learn how to get UUID in Linux, you can try this method:
- Launch your Linux system’s Terminal.
- Type
blkid
and press Enter to display a list of devices along with their UUIDs. - Optionally, use
blkid -s UUID
to show only the UUIDs of the devices.
Learn more about how to get UUID in Linux Terminal with five proven methods and how to change the UUID of partition in Linux.
Ever had trouble identifying your devices or files in Linux? Knowing how to find and manage UUIDs (Universally Unique Identifiers) can make this a lot easier. In this post, I’ll show you how to check and change UUIDs in Linux. You’ll learn simple methods to get UUIDs, change them, and fix common errors. With step-by-step instructions using commands like blkid
, lsblk
, and hwinfo
, you’ll gain the skills to handle UUIDs confidently and manage your system more efficiently.
What is UUID?
A UUID, or Universally Unique Identifier, is a unique number used to identify information in computer systems. Think of it as a serial number for your devices and files. A UUID is a 128-bit number and it helps identify devices, files, or data uniquely without any overlap, ensuring smooth operation and avoiding conflicts.
Structure of a UUID
A typical UUID looks like this: 550e8400-e29b-41d4-a716-446655440000
- 128 Bits Long: This length ensures that UUIDs have an extremely low chance of being duplicated.
- 32 Characters: The UUID has 32 characters divided into five groups, separated by hyphens.
- Hexadecimal Digits: It uses hexadecimal digits (0-9 and a-f).
Breakdown of the UUID Structure
- Time-Based: Part of the UUID is based on the current time.
- Randomness: Another part is random, ensuring even more uniqueness.
How to Get UUID in Linux?
To check UUID Linux, you can use the blkid command, which provides a straightforward and direct way to list the UUIDs along with other filesystem information. Open your terminal and type sudo blkid
, and this command will display the UUIDs for all recognized block devices. Ensure you have the necessary permissions to execute this command, as it may require superuser privileges.
Here is the step-by-step guide to using the blkid command and four more methods to find UUID in Linux:
1. blkid Command
The blkid command is a powerful utility that allows you to locate UUIDs in Linux. This method lets you quickly retrieve UUID information for your devices and filesystems. Follow these steps to use the blkid command effectively:
- Open a Terminal on your Linux system.

- Type the following command and press Enter to execute the command:
blkid
The output will display a list of devices and their corresponding UUIDs in Linux.

- Use the -s option only to view UUIDs.

2. Checking /etc/fstab
The /etc/fstab file contains vital information about the filesystems mounted on your Linux system. This method allows you to find UUIds in Linux by examining the contents of this file. You can find UUID in Linux by following these steps:
- Launch the terminal window on your Linux system. Use a text editor to open the /etc/fstab file and run the following command:
sudo nano /etc/fstab
This command will show UUID in a nano text editor.

- Look for lines that contain UUID= followed by a UUID string.

3. lsblk Command
The lsblk
command allows you to list block devices along with their UUIDs. By employing this method, you can obtain a comprehensive view of the devices and their associated UUIDs. To employ this method, follow these steps:
- Launch a terminal on your Linux system and execute the command:
lsblk -o name,uuid
The output will present a list of devices along with their corresponding UUIDs.

4. Using hwinfo
hwinfo is a powerful tool for reporting detailed information about the hardware configuration of the machine. It can also display UUIDs for storage devices among a wide range of other hardware details.
- Open your terminal and run the following command to install hwinfo on your system:
sudo apt-get install hwinfo
This command downloads and installs the hwinfo utility from the repository.

- After installation, execute the command:
sudo hwinfo --disk
This command scans and reports detailed information about all disk devices, including their UUIDs. Review the output displayed in your terminal to locate the UUIDs, which are typically listed under the information for each disk device.

5. Exploring /dev/disk/by-uuid/
The /dev/disk/by-uuid/ directory in Linux contains symbolic links that map UUIDs to their corresponding device files. This setup is crucial for ensuring devices are identified consistently and reliably, regardless of changes in the system’s hardware configuration.
- Open your Terminal and change to the /dev/disk/by-uuid/ directory to view all storage devices identified by their UUIDs:
cd /dev/disk/by-uuid/
This command changes the current directory to /dev/disk/by-uuid/, where you can see links representing each disk partition.

- Execute the command to list the contents of the directory:
ls -l
This command provides a detailed list of all symbolic links in the directory, showing each UUID linked to its respective device file. The result will display symbolic links formatted like this:
- 90b1…… represents the UUID of the partition.
- ../../sda3 indicates the actual device name corresponding to this UUID.

How to Change the UUID of Partition in Linux?
Changing the UUID of partition in Linux is a process that should be done with caution, as it can affect system behavior, especially if the UUID is referenced in system configuration files like /etc/fstab. Here’s how to change the UUID of partition in Linux:
Prerequisites
- Backup your data: Before making any changes to the disk partition, it’s wise to back up any important data.
- Identify the partition: You should know the specific partition whose UUID you wish to change.
Changing the UUID for EXT4 Partitions
- You can list all partitions and their current UUIDs using the blkid command.
blkid

- Before you change the UUID, you need to unmount the partition if it is in use. You can unmount it using:
sudo umount /dev/sdXn
Replace /dev/sdXn with your partition’s device identifier.

- Use tune2fs to change the UUID of the EXT4 partition:
sudo tune2fs -U random /dev/sdXn
This command sets a new random UUID to the partition. You can also set a specific UUID by replacing random with the new UUID string.

- Use blkid to confirm that the UUID has been changed:
sudo blkid /dev/sdXn

Common Errors When Checking Linux UUID
When working with UUIDs in Linux, it’s important to be aware of common errors that can occur. By understanding these errors, you can troubleshoot and resolve them effectively. Here are four common errors related to UUIDs:
- ❌ UUID Not Found: This error happens when you reference a non-existent or incorrect UUID. To fix it, double-check the UUID you are using. Verify the UUID with
blkid /dev/sda1
, and update your configuration files or commands with the correct UUID. - 🔀 UUID Conflict: A conflict occurs when two partitions share the same UUID, causing confusion and potential data loss. Change the UUID of one partition using
sudo tune2fs -U new_uuid /dev/sda1
ormkfs
with the-U
option. Update your system configuration and references accordingly. - ❓ Incorrect UUID Reference: Errors can arise from incorrect UUID references in configuration files or scripts. Review the affected files and ensure the UUIDs are accurate. Update the references with the correct UUIDs to restore functionality.
- 🔄 UUID Changes After Disk Replacement: Replacing a disk or migrating data can change the UUID of a partition. Update your configuration files, scripts, or commands with the new UUID. Use
blkid /dev/sdb1
to find the new UUID and make the necessary changes in your system.
Linux Get UUID: Final Thoughts
In this guide, I showed you various methods to check UUIDs in Linux, such as using blkid
, lsblk
, and hwinfo
, and by exploring the /etc/fstab
file and the /dev/disk/by-uuid/
directory. I also covered how to change a partition’s UUID with tune2fs
and how to handle common UUID-related errors for smooth system management.
If you found this article helpful, I recommend learning more about:
- Finding the UID of a user, which helps you manage and identify user accounts effectively.
- Identifying the PID and PPID, crucial for controlling and debugging processes.
- Running commands in the background, enabling you to multitask and manage long-running operations efficiently.
Frequently Asked Questions
How do I restore a missing UUID in Linux?
blkid
. Then, use a filesystem-specific command, such as tune2fs
for EXT4, to assign a new UUID, for example, sudo tune2fs -U random /dev/sdx
.Can UUIDs be the same on two different devices?
How can I find the UUID of a specific partition?
blkid
command along with the device name. By specifying the device name, you can retrieve the UUID associated with that particular partition. For example, to find the UUID of the /dev/sda1 partition, you can use the following command: blkid /dev/sda1
. Upon execution, the command will display the UUID of the specified partition. Can I use the UUID to mount a partition from the command line?
sudo mount UUID=<UUID> /mnt
. Replace <UUID> with the actual UUID of the partition you want to mount and /mnt with the desired mount point directory. This approach offers a convenient and reliable way to mount specific partitions without relying solely on device names.