lsblk Command in Linux with Examples

Lsblk is used to display details about block devices and these block devices(Except ram disk) are basically those files that represent devices connected to the pc. It queries /sys virtual file system and udev db to obtain information that it displays. And it basically displays output in a tree-like structure. This command comes pre-installed with the util-Linux package.

Installing lsblk Command

Many Linux distributions do not have lsblk command pre-installed. To install it use the following commands as per your Linux distribution.

In case of Debian/Ubuntu

$sudo apt-get install util-linux

In case of CentOS/RedHat

$sudo yum install util-linux-ng

In case of Fedora OS



$sudo yum install util-linux-ng

Working with lsblk command

1. To display block devices.

$lsblk

to-display-block-devices

It displays the list of block devices on your system.

2. To display empty block devices as well.

#lsblk -a

to-display-empty-block-devices

This will display all block devices along with empty ones.

3. To print size information in bytes.

$lsblk -b

display-block-devices-in-bytes



It displays all the block devices along with their sizes in bytes.

4. To print zone model for devices.

$lsblk -z

print-zone-model-block-devices

5. To skip slave entries.

$lsblk -d

to-avoid-slaves

This will skip all the slave entries.

6.To use ASCII characters for tree formatting.

$lsblk -i 

block-devices-ASCII-tree-formatting

This will display the tree formatting with ASCII character values.

7. To print information about device owner, group, and mode of block devices.



$lsblk -m

to-display-mode-owner-group-block-device

This will display all details of device owner, group and mode of block devices.

8. To print selected coulumns of block-devices.

$lsblk -o SIZE, NAME, MOUNTPOINT

to-display-specific-columns

This will print only the specified columns.

9. To hide column headings.

$lsblk -dn

hide-column-heading-block-devices

This will hide colummn headings.

10. To display help section of the command.

$lsblk --help

lsblk-help-1

lsblk-help-2

This will display the help section of the command.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.