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

It displays the list of block devices on your system.
2. To display empty block devices as well.
#lsblk -a

This will display all block devices along with empty ones.
3. To print size information in bytes.
$lsblk -b

It displays all the block devices along with their sizes in bytes.
4. To print zone model for devices.
$lsblk -z

5. To skip slave entries.
$lsblk -d

This will skip all the slave entries.
6.To use ASCII characters for tree formatting.
$lsblk -i

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

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

This will print only the specified columns.
9. To hide column headings.
$lsblk -dn

This will hide column headings.
10. To display help section of the command.
$lsblk --help


This will display the help section of the command.



Please Login to comment...