在Linux中,我们使用lsusb命令列出USB设备及其属性,lsusb用于显示系统中USB总线的信息以及连接到它的设备。下面介绍如何安装和使用。系统环境系统:Centos7安装usbutils。Centos7系统默认没有lsusb命令。我们需要安装usbutils安装包才能使用lsusb:[root@localhost~]#yum-yinstallusbutils列出usb设备信息lsusb用于显示系统中USB总线及其连接的设备的信息,下面运行lsusb:[root@localhost~]#lsusbBus001Device010:ID0bda:0129RealtekSemiconductorCorp.RTS5129CardReaderControllerBus001Device055:ID0951:1665KingstonTechnologyDigitalDataTravelerSE964GBBus001Device001:ID1d6b:0002LinuxFoundation2.0roothubBus002Device003:ID0e0f:0002VMware,Inc.VirtualUSBHubBus002Device002:ID0e0f:0003VMware,Inc.VirtualMouseBus002Device001:ID1d6b:0001LinuxFoundation1.1roothublsusbwilldisplaythedriversanddevices系统内部连接。以上输出解释如下:Bus001Device055:ID0951:1665KingstonTechnologyDigitalDataTravelerSE964GBBus001:表示第一个usb控制器,可以使用lspci|grepUSB查看主机有多少个usb控制器Device055:表示系统分配给这个金士顿存储设备的设备号ID:表示usb设备的IDKingstonTechnologyDigitalDataTravelerSE964GB:表示它的制造商名称和设备名称我们还看到还有USB2.0roothubdrivers和USB1.1root附加到系统集线器驱动程序。使用树型显示usb信息使用-t选项以树形结构显示usb信息:[root@localhost~]#lsusb-t/:Bus04.Port1:Dev1,Class=root_hub,Driver=xhci_hcd/4p,5000M/:Bus03.Port1:Dev1,Class=root_hub,Driver=xhci_hcd/4p,480M|__Port1:Dev2,If0,Class=MassStorage,Driver=usb-storage,480M/:Bus02.Port1:Dev1,Class=root_hub,Driver=uhci_hcd/2p,12M|__Port1:Dev2,If0,Class=HumanInterfaceDevice,Driver=usbhid,12M|__Port2:Dev3,If0,Class=Hub,Driver=hub/7p,12M/:Bus01.Port1:Dev1,Class=root_hub,Driver=ehci-pci/6p,480M其中数字12M、480M、5000M表示USB的传输速度。12M表示12Mbit/s,USB1.0/1.1类型480M表示480Mbit/s,USB2.0类型5000M表示5Gbit/s,USB3.0类型Linux从/usr/share/hwdata/usb.ids中识别USB设备的详细信息。lsusb中列出的供应商和设备名称是从此文件中识别的。如何列出USB详细信息使用-v参数查看usb详细信息:[root@localhost~]#lsusb-v|lessBus001Device056:ID0951:1665KingstonTechnologyDigitalDataTravelerSE964GBDeviceDescriptor:bLength18bDescriptorType1bcdUSB2.00bDeviceClass0(DefinedatInterfacelevel)bDeviceSubClass0bDeviceProtocol0bMaxPacketSize064idVendor0x0951KingstonTechnologyidProduct0x1665DigitalDataTravelerSE964GBbcdDevice1.00iManufacturer1KingstoniProduct2DataTraveler2.0iSerial308606E6B6612FD50771C2A8BbNumConfigurations1ConfigurationDescriptor:bLength9bDescriptorType2wTotalLength32bNumInterfaces1bConfigurationValue1iConfiguration0bmAttributes0x80(BusPowered)MaxPower100mAInterfaceDescriptor:bLength9bLength9bDescriptorType4bInterfaceNumber0bAlternateSetting0bNumEndpoints2bInterfaceClass8MassStoragebInterfaceSubClass6SCSIbInterfaceProtocol80Bulk-OnlyiInterface0EndpointDescriptor:bLength7bDescriptorType5bEndpointAddress0x81EP1INbmAttributes2TransferTypeBulkSynchTypeNoneUsageTypeDatawMaxPacketSize0x02001x512bytesbInterval255EndpointDescriptor:bLength7bDescriptorType5bEndpointAddress0x02EP2OUTbmAttributes2TransferTypeBulkSynchTypeNoneUsageTypeDatawMaxPacketSize0x02001x512bytesbInterval255DeviceQualifier(forotherdevicespeed):bLength10bDescriptorType6bcdUSB2.00bDeviceClass0(DefinedatInterfacelevel)bDeviceSubClass0bDeviceProtocol0bMaxPacketSize064bNumConfigurations1DeviceStatus:0x0000(BusPowered)查找连接了多少个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/001combinedwiththelsusbcommandandthe-Dparametercanoutputspecificdevicedetails下面的例子查看金士顿存储设备的详细信息:[root@localhost~]#lsusb-D/dev/bus/usb/001/056找到大容量存储设备lsusb-v为我们提供了非常详细的信息,我们可以配合使用grep命令查找指定信息,过滤掉idVendor和MassStorage获取海量存储设备:[root@localhost~]#lsusb-v|grep-Ei'(idVendor|Mass\Storage)'idVendor0x0bdaRealtekSemiconductorCorp.idVendor0x0951KingstonTechnologybInterfaceClass8MassStorageidVendor0x1d6bendVMoundofoundation,Inc.idVendor0x0e0fVMware,Inc.idVendor0x1d6bLinuxFoundation可以看到只有idVendor为KingstonTechnology的设备才是海量存储设备。本文转载自微信公众号《Linux就该这么学》,可以通过以下二维码关注。转载本文,请联系Linux像这样学习公众号。
