ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

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

2021-04-08 19:53:13  阅读:201  来源: 互联网

标签:usb lsusb 001 dev Linux root USB


图片

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


系统环境

系统:Centos7

安装usbutils

默认Centos7系统中没有lsusb命令,我们需要安装usbutils安装包,才能使用lsusb:
[root@localhost ~]# yum -y install usbutils


列出usb设备信息

lsusb用于显示有关系统中的USB总线及其连接的设备的信息,下面运行lsusb:
[root@localhost ~]# lsusb
Bus 001 Device 010: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 055: ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
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设备的IDKingston Technology Digital DataTraveler SE9 64GB: 表示其制造商名称和设备名称
我们还看到,系统中还附有USB 2.0 root hub 驱动程序和USB 1.1 root hub 驱动程序。
使用树状类型显示usb信息使用-t选项,以树状结构显示usb信息:

[root@localhost ~]# lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/7p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=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详细信息:
[root@localhost ~]# lsusb -v | less

Bus 001 Device 056: ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0951 Kingston Technology
  idProduct          0x1665 Digital DataTraveler SE9 64GB
  bcdDevice            1.00
  iManufacturer           1 Kingston
  iProduct                2 DataTraveler 2.0
  iSerial                 3 08606E6B6612FD50771C2A8B
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval             255
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)



查找连接了多少个USB设备

查找链接的设备数量,可以使用下面命令查找:
[root@localhost ~]# find /dev/bus
/dev/bus
/dev/bus/usb
/dev/bus/usb/002
/dev/bus/usb/002/003
/dev/bus/usb/002/002
/dev/bus/usb/002/001
/dev/bus/usb/001
/dev/bus/usb/001/056
/dev/bus/usb/001/010
/dev/bus/usb/001/001

图片


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

图片


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

图片




查找大容量存储设备

lsusb -v为我们提供了非常详细的信息,我们可以配合使用grep命令查找指定的信息,下面过滤出idVendorMass Storage,来获取大容量存储设备:
[root@localhost ~]# lsusb -v |grep -Ei '(idVendor|Mass\ Storage)'
  idVendor           0x0bda Realtek Semiconductor Corp.
  idVendor           0x0951 Kingston Technology
      bInterfaceClass         8 Mass Storage
  idVendor           0x1d6b Linux Foundation
  idVendor           0x0e0f VMware, Inc.
  idVendor           0x0e0f VMware, Inc.
  idVendor           0x1d6b Linux Foundation

图片


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

图片


标签:usb,lsusb,001,dev,Linux,root,USB
来源: https://blog.51cto.com/u_15127536/2692807

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有