Linux Commands

Linux lsblk Command Tutorial For Beginners

Wikipedia defines a device file or special file as an interface to a device driver that appears in a file system as if it were an ordinary file. Block devices include Hard disks, Flash drives, Optical media, etc.

This tutorial discusses how to use the lsblk command to display information about block devices in a system. The tool utilizes the /sys virtual filesystem to fetch information about the devices. However, it’s worth noting that the tool does not display the RAM disk in the output.

How to Install lsblk?

The lsblk command comes bundled as part of the utils-Linux package that has various low-level system tools. The utils-Linux package also contains tools such as fdisk, login daemon, all of which are essential for Linux system functionality.

To install the package on Ubuntu and Debian based distributions, use the command below:

sudo apt-get install util-linux

For Fedora and REHL family, use the following command:

sudo yum install util-linux-ng

How to Use lsblk?

Without arguments, the lsblk command will display a list of the block devices in a tree-format, as shown below:

sudo lsblk

The output from the lsblk command comes arranged in various columns. The following are the columns from the command and what they represent:

  1. NAME: The first column shows the device name.
  2. MAJ:MIN: The second column, respectively, indicates the major and minor device numbers.
  3. RM: This column displays Boolean values for removable and non-removable devices. 1 indicates that the device is removable, and 0 indicates that the device is non-removable.
  4. SIZE: This displays the device size in a readable format, i.e., In K, M, G, T, etc. You can use the lsblk –bytes /dev/<name> to display the size in bytes.
  5. RO: This column shows the read-only status of a device. 1 indicates the device is read-only, and 0 indicates not read-only.
  6. TYPE: This column shows the type of devices, such as disk, loopback device, partition, or LVM device.
  7. MOUNTPOINT: This displays the mount point on which the device is mounted.

Devices in lsblk output
Some of the devices you will see in the lsblk output are:

  1. Loopback devices: Loopback devices mainly contains ISO image, a disk image, a file system, or a logical volume image. Their main identification is using loop0, loop1, etc.
  2. CD-ROM: They are mainly indicated with sr0 and have properties such as RM of 1.
  3. Disk partitions: The main indicator used for Disk partitions is sda, followed by sda1, sda2…sda(n).

List all devices
The default lsblk command does not display all free devices. To do this, add the -a argument to the command as:

sudo lsblk -a

List format
The lsblk command will display the output in a tree-like format. However, you can change this by using the -l argument as:

sudo lsblk -l

Selective Columns
We can also use -o followed by the names of the columns we want to output for selective information as:


Device Permissions
To view device permissions and ownership, use the command:

sudo lsblk -m

Information about specific devices
To list information about a particular block device, specify the device name in the lsblk command as:

sudo lsblk /dev/sda1

List devices without the header
To remove the header from the output, use the -n flag in the command as:

sudo lsblk -n

Display SCSI Devices
To display SCSI devices only, use the -S flag in the command:

sudo lsblk -S


In this tutorial, we discussed how to work with the lsblk command to display information about block devices that are connected to the system. The only way to master working with this command is to experiment. Therefore, consider experimenting with the commands discussed in this tutorial.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list