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:
Section titled “blkid Syntax:”blkid [options] [device|label|UUID]blkid Options:
Section titled “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:
Section titled “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:
Section titled “blkid Command Usage Examples:”Display Information of a Specific Device
Section titled “Display Information of a Specific Device”blkid /dev/sda1This command displays the information of a specific block device (/dev/sda1).
Display All Block Device Information
Section titled “Display All Block Device Information”blkidExecuting this command will display information about all block devices on the system.
Show UUID of a Specific Device
Section titled “Show UUID of a Specific Device”blkid -s UUID /dev/sda1Displays only the UUID of the specified block device (/dev/sda1).
Display only Filesystem Type of Devices
Section titled “Display only Filesystem Type of Devices”blkid -s TYPEThis will list the filesystem types of all block devices on the system.
Display Information in JSON Format
Section titled “Display Information in JSON Format”blkid --output=jsonFormats the output of blkid command in JSON format for easy parsing and integration with other tools.
How do I use blkid in Linux?
Section titled “How do I use blkid in Linux?”To use the blkid command in bash, execute the following command:
blkidHow to list only specific device information with blkid?
Section titled “How to list only specific device information with blkid?”To list specific device information like UUIDs and labels, use the following command:
blkid /dev/sda1How can I display only UUIDs of block devices using blkid?
Section titled “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:
blkid -o value -s UUIDHow do I force blkid to read devices even if they are in use?
Section titled “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:
blkid -pHow to display information about filesystems with blkid?
Section titled “How to display information about filesystems with blkid?”To display detailed information about filesystems, use the following blkid command:
blkid -s TYPEHow can I show empty partitions with blkid?
Section titled “How can I show empty partitions with blkid?”To display information about empty partitions using blkid, run the following command:
blkid -p -u unmountedHow to ignore specific devices using blkid?
Section titled “How to ignore specific devices using blkid?”To ignore specific devices like CD-ROMs and loop devices when running blkid, use the following command:
blkid -t TYPE=TYPE_TO_IGNOREHow do I save blkid output to a file?
Section titled “How do I save blkid output to a file?”To save blkid output to a file, use the following command:
blkid > blkid_output.txtApplications of the blkid Command
Section titled “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