教你在Linux中使用lsusb命令显示有关USB设备信息

系统 Linux
在Linux中我们使用lsusb命令列出USB设备及其属性,lsusb用于显示系统中的USB总线及其连接的设备信息。下面介绍如何安装并使用。

[[393589]]

 在Linux中我们使用lsusb命令列出USB设备及其属性,lsusb用于显示系统中的USB总线及其连接的设备信息。下面介绍如何安装并使用。

系统环境

系统:Centos7

安装usbutils

默认Centos7系统中没有lsusb命令,我们需要安装usbutils安装包,才能使用lsusb:

  1. [root@localhost ~]# yum -y install usbutils 

列出usb设备信息

lsusb用于显示有关系统中的USB总线及其连接的设备的信息,下面运行lsusb: 

  1. [root@localhost ~]# lsusb  
  2. Bus 001 Device 010: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller  
  3. Bus 001 Device 055: ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB  
  4. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
  5. Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub  
  6. Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse  
  7. Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub 

lsusb将显示系统内部连接的驱动程序和设备。

上面输出内容解释如下:

Bus 001 Device 055: ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB

Bus 001: 表示第一个usb控制器,可以使用lspci|grep USB查看主机有几个usb控制器

Device 055: 表示系统分配给这个金士顿存储设备的设备号

ID: 表示usb设备的ID

Kingston Technology Digital DataTraveler SE9 64GB: 表示其制造商名称和设备名称

我们还看到,系统中还附有USB 2.0 root hub 驱动程序和USB 1.1 root hub 驱动程序。

使用树状类型显示usb信息

使用-t选项,以树状结构显示usb信息: 

  1. [root@localhost ~]# lsusb -t  
  2. /:  Bus 04.Port 1: Dev 1, Class=root_hubDriver=xhci_hcd/4p, 5000M  
  3. /:  Bus 03.Port 1: Dev 1, Class=root_hubDriver=xhci_hcd/4p, 480M  
  4.     |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M  
  5. /:  Bus 02.Port 1: Dev 1, Class=root_hubDriver=uhci_hcd/2p, 12M  
  6.     |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M  
  7.     |__ Port 2: Dev 3, If 0, Class=HubDriver=hub/7p, 12M  
  8. /:  Bus 01.Port 1: Dev 1, Class=root_hubDriver=ehci-pci/6p, 480M 

数字12M、480M、5000M表示USB的传输速度。

  •  12M表示12Mbit / s,这是USB 1.0 / 1.1类型
  •  480M表示480Mbit / s,这是USB 2.0类型
  •  5000M表示5Gbit / s,这是USB3.0类型

Linux从/usr/share/hwdata/usb.ids'识别USB设备的详细信息。lsusb列出的vendor和device name都是从这个文件里面识别出来的。

如何列出USB详细信息

使用-v参数查看usb详细信息: 

  1. [root@localhost ~]# lsusb -v | less  
  2. Bus 001 Device 056: ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB  
  3. Device Descriptor:  
  4.   bLength                18  
  5.   bDescriptorType         1  
  6.   bcdUSB               2.00  
  7.   bDeviceClass            0 (Defined at Interface level)  
  8.   bDeviceSubClass         0   
  9.   bDeviceProtocol         0   
  10.   bMaxPacketSize0        64  
  11.   idVendor           0x0951 Kingston Technology  
  12.   idProduct          0x1665 Digital DataTraveler SE9 64GB  
  13.   bcdDevice            1.00  
  14.   iManufacturer           1 Kingston  
  15.   iProduct                2 DataTraveler 2.0  
  16.   iSerial                 3 08606E6B6612FD50771C2A8B  
  17.   bNumConfigurations      1  
  18.   Configuration Descriptor:  
  19.     bLength                 9  
  20.     bDescriptorType         2  
  21.     wTotalLength           32  
  22.     bNumInterfaces          1  
  23.     bConfigurationValue     1  
  24.     iConfiguration          0   
  25.     bmAttributes         0x80  
  26.       (Bus Powered)  
  27.     MaxPower              100mA  
  28.     Interface Descriptor:  
  29.       bLength                 9  
  30.       bLength                 9  
  31.       bDescriptorType         4  
  32.       bInterfaceNumber        0  
  33.       bAlternateSetting       0  
  34.       bNumEndpoints           2  
  35.       bInterfaceClass         8 Mass Storage  
  36.       bInterfaceSubClass      6 SCSI  
  37.       bInterfaceProtocol     80 Bulk-Only  
  38.       iInterface              0   
  39.       Endpoint Descriptor:  
  40.         bLength                 7  
  41.         bDescriptorType         5  
  42.         bEndpointAddress     0x81  EP 1 IN  
  43.         bmAttributes            2  
  44.           Transfer Type            Bulk  
  45.           Synch Type               None  
  46.           Usage Type               Data  
  47.         wMaxPacketSize     0x0200  1x 512 bytes  
  48.         bInterval             255  
  49.       Endpoint Descriptor:  
  50.         bLength                 7  
  51.         bDescriptorType         5  
  52.         bEndpointAddress     0x02  EP 2 OUT  
  53.         bmAttributes            2  
  54.           Transfer Type            Bulk  
  55.           Synch Type               None  
  56.           Usage Type               Data  
  57.         wMaxPacketSize     0x0200  1x 512 bytes  
  58.         bInterval             255  
  59. Device Qualifier (for other device speed):  
  60.   bLength                10  
  61.   bDescriptorType         6  
  62.   bcdUSB               2.00  
  63.   bDeviceClass            0 (Defined at Interface level)  
  64.   bDeviceSubClass         0   
  65.   bDeviceProtocol         0   
  66.   bMaxPacketSize0        64  
  67.   bNumConfigurations      1  
  68. Device Status:     0x0000  
  69.   (Bus Powered) 

查找连接了多少个USB设备

查找链接的设备数量,可以使用下面命令查找: 

  1. [root@localhost ~]# find /dev/bus  
  2. /dev/bus  
  3. /dev/bus/usb  
  4. /dev/bus/usb/002  
  5. /dev/bus/usb/002/003  
  6. /dev/bus/usb/002/002  
  7. /dev/bus/usb/002/001  
  8. /dev/bus/usb/001  
  9. /dev/bus/usb/001/056  
  10. /dev/bus/usb/001/010  
  11. /dev/bus/usb/001/001 

结合使用lsusb命令和-D参数,可以输出特定设备的详细信息。下面实例查看金士顿存储设备的详细信息:

  1. [root@localhost ~]# lsusb -D /dev/bus/usb/001/056 

查找大容量存储设备

lsusb -v为我们提供了非常详细的信息,我们可以配合使用grep命令查找指定的信息,下面过滤出idVendor和Mass Storage,来获取大容量存储设备: 

  1. [root@localhost ~]# lsusb -v |grep -Ei '(idVendor|Mass\ Storage)'  
  2.   idVendor           0x0bda Realtek Semiconductor Corp.  
  3.   idVendor           0x0951 Kingston Technology  
  4.       bInterfaceClass         8 Mass Storage  
  5.   idVendor           0x1d6b Linux Foundation  
  6.   idVendor           0x0e0f VMware, Inc.  
  7.   idVendor           0x0e0f VMware, Inc.  
  8.   idVendor           0x1d6b Linux Foundation 

可以看到只有idVendor是Kingston Technology的设备才是大容量存储设备。 

 

责任编辑:庞桂玉 来源: 良许Linux
相关推荐

2021-03-17 08:07:28

Linux Lsusb命令

2010-12-29 10:48:49

虚拟机

2023-07-04 16:36:03

Linuxcd 命令

2023-07-23 19:26:18

Linuxcat 命令

2023-08-12 15:05:26

Linuxcp 命令

2020-12-07 06:25:14

Linux Truncate 命令

2018-08-21 09:00:30

Linuxtop命令

2023-01-13 23:21:29

netcat命令Linux

2009-06-16 09:06:37

JavaMailJSP

2022-09-11 20:27:17

UbuntuLinux

2022-10-18 10:00:09

Linuxtcpdump命令

2018-11-05 13:50:44

Linux命令tcpdump

2013-07-02 10:25:03

LinuxUSB设备

2010-02-07 11:13:04

Android设备间

2013-05-14 10:13:06

WindowsLinux操作系统

2023-03-14 08:17:40

Bash编程语言

2021-01-04 05:43:59

LinuxBasename命令

2022-10-25 09:07:28

Linuxxargs命令

2022-09-28 12:57:13

USBLinux系统

2022-11-01 16:19:47

Powershell开源命令
点赞
收藏

51CTO技术栈公众号