The Wayback Machine - https://web.archive.org/web/20230512155925/https://www.geeksforgeeks.org/lsblk-command-in-linux-with-examples/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

lsblk Command in Linux with Examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 columns 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 column headings. 

10. To display help section of the command.  

$lsblk --help 

lsblk-help-1lsblk-help-2

This will display the help section of the command.
 

My Personal Notes arrow_drop_up
Last Updated : 27 Sep, 2021
Like Article
Save Article
Similar Reads