Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the lsblk command in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the lsblk command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

The lsblk command is used to view information about block devices. Main application scenarios: obtain wwnid, block device list, block device type (ssd,hdd), size and other information.

System environment

Centos7

Install lsblk

The command lsblk is included in the package util-linux, which comes with some other utilities, such as dmesg. If you want to install lsblk, you can install it using the following command

[root@localhost ~] # yum-y install util-linuxlsblk explanation of each field

By default, the lsblk command lists all block devices in a tree format:

[root@localhost ~] # lsblk

There are seven columns, and the following is the explanation for each field: NAME: this is the name of the block device.

MAJ:MIN: displays the primary and secondary device numbers of the device, MAJ (major number) represents different device types, and MIN (minor number) represents different partitions of the same device.

RM: displays whether the device is mobile. Note that in this example, the RM value of the device sr0 is equal to 1, indicating that it is removable.

SIZE: provides information about setting capacity.

RO: displays whether the device is read-only. In this case, the RO of all devices is RO = 0, indicating that they are not read-only.

TYPE: displays information about whether the block device is a disk or a partition (part) in the disk. In this example, sda and sdb are disks, and sr0 is read-only memory (rom).

MOUNTPOINT: displays the mount point of the device.

List all Devic

The default option does not list all empty devices. To view these contents, you can also use the following command:

[root@localhost ~] # lsblk-a lists device permissions and owners

To list device owners, groups, and permissions, use the-m option:

[root@localhost ~] # lsblk-m lists specified devices

You can also list specified devices by adding the location and name of the device after the lsblk command.

[root@localhost ~] # lsblk / dev/sda lists devices in the form of a list without a header

To delete the title and list output format, use the-nl option.

[root@localhost ~] # lsblk-nl lists SCSI devices

To display only the list of SCSI devices, use the-S option.

[root@localhost ~] # lsblk-S Custom output Type

You can use-- output to customize the displayed fields:

[root@localhost] # lsblk-l-output NAME,SIZE,TYPE,TRAN,STATE Thank you for reading this article carefully. I hope the article "how to use lsblk commands in Linux" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report