How to use the lsblk command in Linux
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!