14 September 2021
1 min read

Lsblk Command in Linux (List Block Devices)

A Block device is a file referring to a device. The devices can be HDDs, SDD’s, RAM Disks, etc. The block device files can be found under the directory /dev.

In this tutorial, we learn about lsblk command in Linux to list block devices.

lsblk command

lsblk command is used to list information about all available block devices in Linux. lsblk is preinstalled in most Linux Distributions. It comes under the utils-linux package.

Lsblk is normally used to find devices and partitions information. The blkid command can give information such as filesystem and UUID. Whereas df command is used mostly for disk usage and filesystem information.

The simplest form to use lsblk is without any arguments, which will display a list of block devices in a tree format.

$ lsblk

lsblk command output with seven columns such as NAME, MAJ:MIN, RM, SIZE, RO, TYPE, and MOUNTPOINT. Each column is explained:

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 gives information on the size of the device.

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 the block device is a disk or a partition(part) within a disk. In the picture, sda is the disk while sr0 is a read-only memory (rom).

MOUNTPOINT: This column indicates the mount point on which the device is mounted.

Let’s check how to use lsblk command:

01. To list all block devices

Use the option -a to display all devices including empty devices:

$ lsblk -a

02. To change the default lsblk output in tree-like format, use -l option

$ lsblk -l

03. Show specific device

Use lsblk following the device name to display information about a specific device.

For example:

$ lsblk /dev/sda5

04. Display only selective columns

If you want you can display the output of specific columns use the -o option.

For example to list name and size columns type:

$ lsblk -o name,size

05. Display device permissions

You can use lsblk to print each device ownership and permissions using -m option.

$ lsblk -m

06. To Display only SCSI devices use -S option.

$ lsblk -S

07. Display output in ASCII character format.

The default tree format is not user friendly and you can use -i option to display in ASCII format:

$ lsblk -i

08. To display the zone model of each device use -z option.

$ lsblk -z

Conclusion

In this tutorial, we learned how to use lsblk command in Linux to find information about connected block devices. Thanks for reading, please provide your suggestion in the comment section.

Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is the editor-in-chief of Linoxide and has an experienced team of Linux enthusiastic authors who makes this blog awesome. Linoxide is one of the top 20 Linux Blog by whizlabs.

Leave a Reply

Your email address will not be published.

Previous Story

How to Set up CUPS Print Server on Ubuntu 20.04

Next Story

4 Best Linux Phones for Privacy in 2021

Latest from Blog

Top 8 Reasons to Use Garuda Linux

Have you been going back and forth between multiple Linux flavors in search of an exciting experience? Or perhaps you are coming from a Windows or MAC environment and want to try

How to Rename Multiple Files in Linux

In a Linux system, you can easily rename a file using mv command. But, if you have multiple files which you want to rename, in this situation you need some extra tools

How to Install TensorFlow on Ubuntu 20.04

Tensorflow is an open-source platform for machine learning and artificial intelligence. It is developed by the Google Brain team. It contains tools, libraries, and community resources for developers to build ML powered
Go toTop