lsblk Command in Linux with Examples (original) (raw)

Last Updated : 4 Nov, 2025

Understanding the storage devices connected to your Linux system is crucial for efficient system management. The lsblk command, short for "list block devices," is a powerful tool that provides detailed information about block devices such as hard drives, solid-state drives, and other storage-related devices.​

Syntax of lsblk Command in Linux

The basic syntax of the lsblk command is simple:

lsblk [OPTIONS] [DEVICE...]

Here,

Installing lsblk Command in Linux

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

**1. In case of Debian/Ubuntu

sudo apt-get install util-linux

**2. In case of CentOS/RedHat

sudo yum install util-linux-ng

**3. In case of Fedora OS

sudo yum install util-linux-ng

Options Available in lsblk Command

Options Description
-a or --all Display all devices, including empty ones.
-b or --bytes Print sizes in bytes instead of the more human-readable formats.
-i or --inverse Invert the output, showing only non-empty devices.
-l or --list Print output in a list format.
-o or --output Define the output columns to display.
-p or --pairs Display key-value pairs for each device.
-t or --tree Print devices in a tree-like format.
-x or --exclud Exclude devices that match the specified criteria.

Examples of lsblk Command in Linux

**1. How to List All Block Devices in Linux

**To display block devices.

**Command:

lsblk

This command will display a hierarchical view of all block devices connected to your system, including information about partitions and mount points.

**Output:

to-display-block-devices

2. How to Display All Devices, Including Empty Ones

To display empty block devices as well.

**Command:

lsblk -a

This command includes all devices, even empty ones, in the output. It can be useful when you want to see all available devices, including those without any partitions or mount points.

**Output:

to-display-empty-block-devices

3. How to **Print sizes in bytes instead of the more human-readable formats

To print size information in bytes.

**Command:

lsblk -b

The '-b' option displays sizes in bytes. This can be handy when you need precise size information for block devices.

**Output:

display-block-devices-in-bytes

4. How to **Viewing Devices in a Tree-Like Format

The '-t' option organizes devices in a tree-like format, making it easier to visualize the relationships between devices and partitions.

**Command:

lsblk -t

**Output:

viewing devices in tree-like format

viewing devices in tree-like format

5. To print zone model for devices.

**Command:

lsblk -z

**Output:

print-zone-model-block-devices

6. To skip slave entries

**Command:

lsblk -d

This will skip all the slave entries.

**Output:

to-avoid-slaves

7. How to **Invert the output, showing only non-empty devices

To use ASCII characters for tree formatting.

**Command:

lsblk -i

Inverting the output with '-i' will show only non-empty devices. This is useful when you want to focus on devices with existing partitions or mount points.

**Output:

block-devices-ASCII-tree-formatting

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

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

**Command:

lsblk -m

**Output:

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

9. How to **Define the output columns to display

Used to print selected columns of block-devices.

**Command:

lsblk -o SIZE, NAME, MOUNTPOINT

Use '-o' to customize the output columns. In this example, we specify that we only want to see the device name, size, and mount point for each device.

**Output:

to-display-specific-columns

This will print only the specified columns.

10. To hide column headings

This will hide column headings.

**Output:

lsblk -dn

**Output:

hide-column-heading-block-devices

11. To display help section of the command

lsblk --help

This will display the help section of the command.

In this article we discussed the 'lsblk' command which is a vital tool for managing storage devices in Linux, offering detailed insights into hard drives and SSDs. This article covers its syntax, options, and practical applications. 'lsblk', part of the util-Linux package, efficiently queries system files to present a tree-like view of block devices. Examples demonstrate how to list devices, customize output, and visualize storage efficiently.