linux命令查看usb linux命令查看文件內(nèi)容

linux下怎么查找usb對(duì)應(yīng)的設(shè)備,比如鼠標(biāo)....

1、首先Linux 系統(tǒng)使用 /dev 目錄下特定的設(shè)備文件來(lái)標(biāo)識(shí)插入的設(shè)備。會(huì)發(fā)現(xiàn)該目錄下的某些文件,包括 /dev/sda 或者 /dev/hda 表示第一個(gè)主設(shè)備,每個(gè)分區(qū)使用一個(gè)數(shù)字來(lái)表示,比如 /dev/sda1 或 /dev/hda1 表示主設(shè)備的第一個(gè)分區(qū)等。

龍勝網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,龍勝網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為龍勝數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢(qián),請(qǐng)找那個(gè)售后服務(wù)好的龍勝做網(wǎng)站的公司定做!

2、使用 df 命令來(lái)找出插入的 USB 設(shè)備名,查看插入你系統(tǒng)里的每一個(gè)設(shè)備及對(duì)應(yīng)的掛載點(diǎn),你可以使用下圖中的 df 命令檢查 Linux 系統(tǒng)磁盤(pán)空間使用情況:$ df -h。

3、使用 lsblk 命令查找 USB 設(shè)備名。也可以使用下面的 lsblk 命令(列出塊設(shè)備)來(lái)列出插入系統(tǒng)里的所有塊設(shè)備:$ lsblk。

4、使用 fdisk 工具識(shí)別 USB 設(shè)備名。fdisk 是一個(gè)功能強(qiáng)大的工具,用于查看系統(tǒng)中的所有分區(qū)表,包括所有的 USB 設(shè)備,使用 root 權(quán)限執(zhí)行如下命令:$ sudo fdisk -l。

5、使用 dmesg 命令來(lái)識(shí)別出 USB 設(shè)備名,運(yùn)行如下命令來(lái)查看內(nèi)核操作信息,同時(shí)也會(huì)打印出 USB 設(shè)備的信息:$ dmesg。

怎么查看linux usb設(shè)備驅(qū)動(dòng)

下面的信息都是在VMware中運(yùn)行Ubuntu12-04系統(tǒng)上執(zhí)行的。同樣該命令也支持在嵌入式系統(tǒng)中進(jìn)行USB調(diào)試。

一、cat設(shè)備節(jié)點(diǎn)獲取信息

在一些嵌入式開(kāi)發(fā)中需要調(diào)試USB功能,經(jīng)常會(huì)cat /sys 下的相關(guān)設(shè)備節(jié)點(diǎn)來(lái)查看某些信息,比如說(shuō)我們可以看到 /sys/bus/usb/devices 目錄有多個(gè)子目錄。進(jìn)入到某個(gè)子目錄可以看到usb設(shè)備更加詳細(xì)的信息(可以理解為設(shè)備描述符)。

1、usb設(shè)備在總線上的信息

// usb設(shè)備在總線上的信息

root@ubuntu:/sys/kernel/debug# cd /sys/bus/usb/devices

root@ubuntu:/sys/bus/usb/devices# ll

total 0

drwxr-xr-x 2 root root 0 Nov 26 21:21 ./

drwxr-xr-x 4 root root 0 Nov 26 21:21 ../

lrwxrwxrwx 1 root root 0 Nov 26 21:21 1-0:1.0 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-0:1.0/

lrwxrwxrwx 1 root root 0 Dec 15 23:10 1-1 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/

lrwxrwxrwx 1 root root 0 Dec 15 23:18 1-1:1.0 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-0:1.0 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-0:1.0/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1:1.0 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/2-1:1.0/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2:1.0 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2:1.0/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb1 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/

lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb2 - ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/

其中 usbx/第x個(gè)總線,x-y:a.b/的目錄格式,x表示總線號(hào),y表示端口,a表示配置,b表示接口。

具體解釋可以參照如下:

The names that begin with "usb" refer to USB controllers. More accurately, they refer to the "root hub" associated with each controller. The number is the USB bus number. In the example there is only one controller, so its bus is number 1. Hence the name "usb1".

"1-0:1.0" is a special case. It refers to the root hub's interface. This acts just like the interface in an actual hub an almost every respect; see below.

All the other entries refer to genuine USB devices and their interfaces. The devices are named by a scheme like this:

bus-port.port.port ...

In other words, the name starts with the bus number followed by a '-'. Then comes the sequence of port numbers for each of the intermediate hubs along the path to the device.

For example, "1-1" is a device plugged into bus 1, port 1. It happens to be a hub, and "1-1.3" is the device plugged into port 3 of that hub. That device is another hub, and "1-1.3.1" is the device plugged into its port 1.

The interfaces are indicated by suffixes having this form:

:config.interface

That is, a ':' followed by the configuration number followed by '.' followed by the interface number. In the above example, each of the devices is using configuration 1 and this configuration has only a single interface, number 0. So the interfaces show up as;

1-1:1.0 1-1.3:1.0 1-1.3.1:1.0

A hub will never have more than a single interface; that's part of the USB spec. But other devices can and do have multiple interfaces (and sometimes multiple configurations). Each interface gets its own entry in sysfs and can have its own driver.

2、特定設(shè)備的詳細(xì)信息

進(jìn)入到某個(gè)目錄中去,可以看到該設(shè)備的詳細(xì)信息,可用cat命令獲取信息。

// usb設(shè)備的詳細(xì)信息

root@ubuntu:/sys/bus/usb/devices/usb1# ll

total 0

drwxr-xr-x 6 root root 0 Nov 26 21:21 ./

drwxr-xr-x 4 root root 0 Nov 26 21:21 ../

drwxr-xr-x 10 root root 0 Nov 26 21:21 1-0:1.0/

drwxr-xr-x 5 root root 0 Dec 15 23:10 1-1/

-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized

-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized_default

-rw-r--r-- 1 root root 4096 Dec 15 23:40 avoid_reset_quirk

-r--r--r-- 1 root root 4096 Nov 26 21:21 bcdDevice

-rw-r--r-- 1 root root 4096 Nov 26 21:21 bConfigurationValue

-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceClass

-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceProtocol

-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceSubClass

-r--r--r-- 1 root root 4096 Dec 15 23:40 bmAttributes

-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPacketSize0

-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPower

-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumConfigurations

-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumInterfaces

-r--r--r-- 1 root root 4096 Nov 26 21:21 busnum

-r--r--r-- 1 root root 4096 Dec 15 23:40 configuration

-r--r--r-- 1 root root 65553 Nov 26 21:21 descriptors

-r--r--r-- 1 root root 4096 Dec 15 23:40 dev

-r--r--r-- 1 root root 4096 Nov 26 21:21 devnum

-r--r--r-- 1 root root 4096 Dec 15 23:40 devpath

lrwxrwxrwx 1 root root 0 Nov 27 20:06 driver - ../../../../../bus/usb/drivers/usb/

drwxr-xr-x 3 root root 0 Dec 15 23:40 ep_00/

-r--r--r-- 1 root root 4096 Nov 26 21:21 idProduct

-r--r--r-- 1 root root 4096 Nov 26 21:21 idVendor

-r--r--r-- 1 root root 4096 Dec 15 23:40 ltm_capable

-r--r--r-- 1 root root 4096 Nov 26 21:21 manufacturer

-r--r--r-- 1 root root 4096 Dec 15 23:40 maxchild

drwxr-xr-x 2 root root 0 Nov 26 21:21 power/

-r--r--r-- 1 root root 4096 Nov 26 21:21 product

-r--r--r-- 1 root root 4096 Dec 15 23:40 quirks

-r--r--r-- 1 root root 4096 Nov 26 21:21 removable

--w------- 1 root root 4096 Dec 15 23:40 remove

-r--r--r-- 1 root root 4096 Nov 26 21:21 serial

-r--r--r-- 1 root root 4096 Nov 26 21:21 speed

lrwxrwxrwx 1 root root 0 Nov 26 21:21 subsystem - ../../../../../bus/usb/

-rw-r--r-- 1 root root 4096 Nov 26 21:21 uevent

-r--r--r-- 1 root root 4096 Dec 15 23:40 urbnum

-r--r--r-- 1 root root 4096 Dec 15 23:40 version

二、使用debugfs

1、掛載 debugfs 到 /sys/kernel/debug 路徑下

root@ubuntu:mount -t debugfs none /sys/kernel/debug

2、執(zhí)行上述步驟之后,在 /sys/kernel/debug 就會(huì)生成如下的文件

root@ubuntu:/sys/bus/usb/devices# cd /sys/kernel/debug/

root@ubuntu:/sys/kernel/debug# ll

total 0

drwx------ 22 root root 0 Nov 26 21:21 ./

drwxr-xr-x 7 root root 0 Nov 26 21:21 ../

drwxr-xr-x 2 root root 0 Nov 26 21:21 acpi/

drwxr-xr-x 32 root root 0 Dec 4 16:30 bdi/

drwxr-xr-x 2 root root 0 Nov 26 21:21 bluetooth/

drwxr-xr-x 2 root root 0 Nov 26 21:21 cleancache/

drwxr-xr-x 2 root root 0 Nov 26 21:21 dma_buf/

drwxr-xr-x 4 root root 0 Nov 26 21:21 dri/

drwxr-xr-x 2 root root 0 Nov 26 21:21 dynamic_debug/

drwxr-xr-x 2 root root 0 Nov 26 21:21 extfrag/

drwxr-xr-x 2 root root 0 Nov 26 21:21 frontswap/

-r--r--r-- 1 root root 0 Nov 26 21:21 gpio

drwxr-xr-x 3 root root 0 Nov 26 21:21 hid/

drwxr-xr-x 2 root root 0 Nov 26 21:21 kprobes/

drwxr-xr-x 3 root root 0 Nov 26 21:21 kvm-guest/

drwxr-xr-x 2 root root 0 Nov 26 21:21 mce/

drwxr-xr-x 2 root root 0 Nov 26 21:21 pinctrl/

-r--r--r-- 1 root root 0 Nov 26 21:21 pwm

drwxr-xr-x 2 root root 0 Nov 26 21:21 regmap/

drwxr-xr-x 3 root root 0 Nov 26 21:21 regulator/

-rw-r--r-- 1 root root 0 Nov 26 21:21 sched_features

-r--r--r-- 1 root root 0 Nov 26 21:21 sleep_time

-r--r--r-- 1 root root 0 Nov 26 21:21 suspend_stats

drwxr-xr-x 7 root root 0 Nov 26 21:21 tracing/

drwxr-xr-x 3 root root 0 Nov 26 21:21 usb/

drwxr-xr-x 2 root root 0 Nov 26 21:21 virtio-ports/

-r--r--r-- 1 root root 0 Nov 26 21:21 vmmemctl

-r--r--r-- 1 root root 0 Nov 26 21:21 wakeup_sources

drwxr-xr-x 2 root root 0 Nov 26 21:21 x86/

3、cat 設(shè)備節(jié)點(diǎn)

執(zhí)行下述命令之后會(huì)以特定格式打印目前USB總線上所有USB設(shè)備的信息如下:

root@ubuntu:/sys/kernel/debug# cat usb/devices

T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2

B: Alloc= 17/900 us ( 2%), #Int= 1, #Iso= 0

D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1

P: Vendor=1d6b ProdID=0001 Rev= 3.13

S: Manufacturer=Linux 3.13.0-32-generic uhci_hcd

S: Product=UHCI 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

E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms

T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0

D: Ver= 1.10 Cls=00(ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1

P: Vendor=0e0f ProdID=0003 Rev= 1.03

S: Manufacturer=VMware

S: Product=VMware Virtual USB Mouse

C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA

I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid

E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=1ms

T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 7

D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1

P: Vendor=0e0f ProdID=0002 Rev= 1.00

S: Product=VMware Virtual USB Hub

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

E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms

T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6

B: Alloc= 0/800 us ( 0%), #Int= 1, #Iso= 0

D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1

P: Vendor=1d6b ProdID=0002 Rev= 3.13

S: Manufacturer=Linux 3.13.0-32-generic ehci_hcd

S: Product=EHCI Host Controller

S: SerialNumber=0000:02:03.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

E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms

T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0

D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1

P: Vendor=0bda ProdID=0129 Rev=39.60

S: Manufacturer=Generic

S: Product=USB2.0-CRW

S: SerialNumber=20100201396000000

C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=500mA

I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=50 Driver=rts5139

E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

E: Ad=83(I) Atr=03(Int.) MxPS= 3 Ivl=64ms

至于信息的詳細(xì)解析可以參照 Linux源代碼中 Documentation/usb/proc_usb_info.txt 文件?,F(xiàn)摘錄其中對(duì)該格式的詳細(xì)解釋:

| | |__Product ID code

| |__Vendor ID code

|__Device info tag #2

String descriptor info:

S: Manufacturer=ssss

| |__Manufacturer of this device as read from the device.

| For USB host controller drivers (virtual root hubs) this may

| be omitted, or (for newer drivers) will identify the kernel

| version and the driver which provi

linux系統(tǒng)怎么查看usb接口信息

系統(tǒng)插入U(xiǎn)SB設(shè)備后,從控制臺(tái)界面有如下提示:從控制臺(tái)信息可以看出插入的USB設(shè)備名。

標(biāo)題名稱:linux命令查看usb linux命令查看文件內(nèi)容
轉(zhuǎn)載注明:http://muchs.cn/article34/dohoope.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、商城網(wǎng)站品牌網(wǎng)站設(shè)計(jì)、外貿(mào)建站軟件開(kāi)發(fā)、標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)