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

What is the use of the lsblk command in Linux

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

Share

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

This article mainly shows you "what is the use of the lsblk command in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of lsblk command in Linux" this article.

The Linux common command lsblk command is used to list information about all available block devices and also shows the dependencies between them, but it does not list information about RAM disks.

Lsblk lists block device information

Supplementary note: block devices include hard drives, flash drives, cd-ROM and so on. The lsblk command is included in the util-linux-ng package, which is now renamed util-linux. This package comes with several other tools, such as dmesg. To install lsblk, download the util-linux package here. Fedora users can install the package by using the command sudo yum install util-linux-ng.

The option-a,-- all # displays all devices. -b,-- bytes # displays the device size in bytes. -d,-- nodeps # does not display slaves or holders. -D,-- discard # print discard capabilities -e,-- exclude # exclude devices (default: RAM disks). -f,-- fs # displays file system information. -h,-- help # displays help information. -I,-- ascii # use ascii characters only -m,-- perms # displays permission information. -l,-- list # is displayed in list format. -n,-- noheadings # does not display the title. -o,-- output # output column. -P,-- pairs # is displayed in key= "value" format. -r,-- raw # is displayed in the original format. -t,-- topology # displays topology information. The instance lsblk command lists all block devices in a tree by default. Open the terminal and enter the following command:

Lsblk NAME MAJ:MIN rm SIZE RO type mountpoint sda8: 0 0 232.9G 0 disk ├─ sda1 8:1 0 46.6G 0 part / ├─ sda2 8:2 0 1K 0 part ├─ sda5 8:5 0 190M 0 part / boot ├─ sda6 8:6 0 3.7G 0 part [SWAP] ├─ sda7 8:7 0 93.1G 0 part / data └─ sda8 8:8 0 89.2G 0 part / Personal sr0 11:0 1 1024M 0 rom7 columns are named as follows:

NAME: this is the name of the block device.

MAJ:MIN: this column shows the primary and secondary device numbers.

RM: this column shows whether the device is removable. Note that in this example, the RM values of devices sdb and sr0 are equal to 1, indicating that they are removable devices.

SIZE: this column lists the capacity size information of the device. For example, 298.1g indicates that the size of the device is 298.1GB, while 1K indicates that the size of the device is 1KB.

RO: this item indicates whether the device is read-only. In this case, all devices have a Ro value of 0, indicating that they are not read-only.

TYPE: this column shows whether the block device is a disk or a partition on the disk. In this example, sda and sdb are disks, while sr0 is read-only storage (rom).

MOUNTPOINT: this column indicates the mount point of the device.

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

The lsblk-alsblk command can also be used to list the ownership relationships of a particular device, as well as groups and patterns. You can obtain this information with the following command:

Lsblk-m this command can also get only the information about the specified device. This can be achieved by specifying the device name after the options provided to the lsblk command. For example, you may be interested in knowing how to display your disk drive size in bytes, then you can do this by running the following command:

Lsblk-b / dev/sda is equivalent to lsblk-- bytes / dev/sda you can also combine several options to get the specified output. For example, you might want to list devices in a list format instead of the default tree format. You may also be interested in removing headings from different column names. You can combine two different options to get the desired output, as follows:

Lsblk-nl to get a list of SCSI devices, you can only use the-S option. This option is an uppercase S and cannot be confused with the-s option, which is used to print dependencies in reverse order.

Lsblk-Slsblk lists SCSI devices, while-s is the reverse option (reversing the organizational relationship between devices and partitions), which gives the following output. Enter the command:

Lsblk-s above are all the contents of this article entitled "what is the use of lsblk commands in Linux?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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