我想查看是否存在 USB 设备,但我没有 lsusb。
有没有其他方法可以检查 USB 设备是否存在而无需使用 lsusb?
答案1
mount -t usbfs none /proc/bus/usb
cat /proc/bus/usb/devices
如果您没有usbfs
模块或/proc/bus/usb
目录,请尝试此操作
cat /sys/bus/usb/devices/*/product
答案2
# cat /sys/kernel/debug/usb/devices
答案3
你也可以尝试这个命令
$ usb-devices
它会给你这样的东西,
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 1
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev=03.19
S: Manufacturer=Linux 3.19.0-59-generic xhci-hcd
S: Product=xHCI Host Controller
S: SerialNumber=0000:02:00.0
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 4
D: Ver= 2.10 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=2109 ProdID=3431 Rev=04.20
S: Product=USB2.0 Hub
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=5000 MxCh= 4
D: Ver= 3.00 Cls=09(hub ) Sub=00 Prot=03 MxPS= 9 #Cfgs= 1
P: Vendor=1d6b ProdID=0003 Rev=03.19
S: Manufacturer=Linux 3.19.0-59-generic xhci-hcd
S: Product=xHCI Host Controller
S: SerialNumber=0000:02:00.0
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=03 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev=03.19
S: Manufacturer=Linux 3.19.0-59-generic ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=0000:00:12.2
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=04 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev=03.19
S: Manufacturer=Linux 3.19.0-59-generic ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=0000:00:13.2
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=04 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=480 MxCh= 4
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=05e3 ProdID=0608 Rev=77.64
S: Product=USB2.0 Hub
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=05 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 3
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev=03.19
S: Manufacturer=Linux 3.19.0-59-generic ohci_hcd
S: Product=OHCI PCI host controller
S: SerialNumber=0000:00:12.0
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=05 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=04ca ProdID=0061 Rev=01.00
S: Manufacturer=PixArt
S: Product=USB Optical Mouse
C: #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
答案4
这取决于您需要做什么和想看到什么。探索 /sys/bus/usb 下的设备条目可能已经足够了。
另一种方法是使用 udev 来管理检测特定 USB 设备时的特定操作。网络上有很多示例,但例如在插入特定 USB 拇指驱动器时,您可以让 udev 创建一个设备条目,例如 /dev/MyThumbdrive,而不是 /dev/sdd1 或除 /dev/sdd1 之外。