0
0
Linux-cliHow-ToBeginner · 3 min read

How to Use lsblk Command in Linux: Syntax and Examples

Use the lsblk command in Linux to list information about block devices like disks and partitions. Run lsblk alone to see a tree view of devices or add options like -f to show filesystem info or -o to customize output columns.
📐

Syntax

The basic syntax of the lsblk command is:

  • lsblk [options] - Lists block devices.
  • -f - Shows filesystem information.
  • -o - Specifies which columns to display.
  • -a - Includes empty devices.
  • -r - Outputs raw data without tree formatting.
bash
lsblk [options]
💻

Example

This example shows how to use lsblk to list all block devices with filesystem details.

bash
lsblk -f
Output
NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 ext4 1234abcd-56ef-7890-ab12-3456ijklmnop /boot ├─sda2 swap 5678efgh-90ab-cdef-1234-5678mnopqrstu [SWAP] └─sda3 ext4 9abcde12-3456-7890-abcd-ef1234567890 / sdb └─sdb1 ntfs Data 0123abcd-4567-89ef-gh01-2345ijklmnop /mnt/data
⚠️

Common Pitfalls

Common mistakes when using lsblk include:

  • Running lsblk without sudo may hide some devices depending on permissions.
  • Expecting detailed filesystem info without using -f option.
  • Misreading the tree structure; child devices are indented under their parent device.
bash
lsblk
# vs
sudo lsblk -f
📊

Quick Reference

OptionDescription
-fShow filesystem type, label, and UUID
-oSpecify output columns (e.g., NAME,SIZE,MOUNTPOINT)
-aInclude empty devices
-rRaw output without tree formatting
-hShow help information

Key Takeaways

Use lsblk to list block devices and their partitions in a clear tree format.
Add -f to see filesystem details like type and mount points.
Use -o to customize which columns to display for focused info.
Run lsblk with sudo if some devices do not appear.
Understand the tree structure to identify parent and child devices correctly.