Lsblk command in Linux is used to list information about all available block devices, however, it does not list information about RAM disks. Examples of block devices are a hard disk, flash drives, CD-ROM e.t.c
Fedora users can install the package as follows:
$ sudo yum install util-linux-ng
The lsblk command by default will list all block devices in a tree-like format. Open your terminal, type:
There are seven columns namely:
NAME: This is the device name.
MAJ:MIN: This column shows the major and minor device number.
RM: This column shows whether the device is removable or not. Note in this example the device sdb and sr0 have their RM values equals to 1 indicating they are removable.
SIZE: This is column give information on the size of the device. For example, 298.1G indicate the device is 298.1GB and 1K indicate the device size is 1KB.
RO: This indicates whether a device is read-only. In this case all devices have a RO=0, indicating they are not read only.
TYPE: This column shows information whether the block device is a disk or a partition(part) within a disk. In this example, sda and sdb are disks while sr0 is a read-only memory (rom).
MOUNTPOINT: This column indicates mount point on which the device is mounted.
List All Devices
The default option does not list all empty devices. To view these also use the command as follows:
$ lsblk -a
Print size column in bytes
To print size column in bytes use -b or --bytes option.
For example to print all partitions in the hard disk (/dev/sda) with size in bytes, run:
$ lsblk --bytes /dev/sda
List Device Permissions and Owner
To list the device ownership, group and mode (permissions) use -m option.
$ lsblk -m
List Specific Devices
It is possible also to get information about a specific device only. This can be achieved by specifying the device name after the option supplied to lsblk.
$ lsblk /dev/sda
List Devices Without Header in List Form
To remove header and list output format, use -nl option.
$ lsblk -nl
List SCSI Devices
To get a list of only SCSI devices use -S option.
$ lsblk -S
In this tutorial, we learned how to use lsblk command to list more information about your block devices, try it out today!