What is blkid Linux command?
The Linux blkid command is used to locate or print block device attributes such as label, UUID, or file system type. It helps in identifying storage devices connected to the system.
blkid Syntax:
blkid Options:
Option | Description |
---|---|
-c | Read cache from the specified file |
-o | Output in the specified format |
-s | Comma-separated list of items to display |
-g | Use the e2fsprogs ext2/ext3 UUID |
-p | Look in the specified directory for devices |
-t | Probe for filesystems only |
-u | Comma-separated list of items to update in the cache |
-l | List known filesystems |
Parameters:
Parameter | Description |
---|---|
[device] | Specify the device to query for |
[label] | Search for devices by label |
[UUID] | Search for devices by UUID |
blkid Command Usage Examples:
Display Information of a Specific Device
This command displays the information of a specific block device (/dev/sda1).
Display All Block Device Information
Executing this command will display information about all block devices on the system.
Show UUID of a Specific Device
Displays only the UUID of the specified block device (/dev/sda1).
Display only Filesystem Type of Devices
This will list the filesystem types of all block devices on the system.
Display Information in JSON Format
Formats the output of blkid command in JSON format for easy parsing and integration with other tools.
How do I use blkid in Linux?
To use the blkid command in bash, execute the following command:
How to list only specific device information with blkid?
To list specific device information like UUIDs and labels, use the following command:
How can I display only UUIDs of block devices using blkid?
To display only the UUIDs of block devices using blkid, run the following command:
How do I force blkid to read devices even if they are in use?
To force blkid to read devices even if they are in use, use the following command:
How to display information about filesystems with blkid?
To display detailed information about filesystems, use the following blkid command:
How can I show empty partitions with blkid?
To display information about empty partitions using blkid, run the following command:
How to ignore specific devices using blkid?
To ignore specific devices like CD-ROMs and loop devices when running blkid, use the following command:
How do I save blkid output to a file?
To save blkid output to a file, use the following command:
Applications of the blkid Command
- Retrieving information about block devices
- Displaying UUIDs and file system types
- Finding information about partitions and storage devices
- Identifying device attributes
- Automating tasks in shell scripts