error: insufficient permissions for device(解决adb shell问题)
今天在Linux下连接平板usb,试用adb shell时出现error: insufficient permissions for device,
而且我们输入adb devices显示:
xxnan@xxnan-pt:~$ adb devices
List of devices attached
???????????? device
那么我们怎么解决它呢?
首先在终端查看usb的ID,输入lsusb命令,我们可以看到我们刚插如usb的ID号,如:
xxnan@xxnan-pt:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 0461:4d80 Primax Electronics, Ltd
Bus 001 Device 004: ID 1c7a:0801 LighTuning Technology Inc. Fingerprint Reader
Bus 002 Device 003: ID 5986:0190 Acer, Inc
Bus 001 Device 019: ID 0bb4:0c02 High Tech Computer Corp. Dream / ADP1 / G1 / Magic / Tattoo (Debug)
其中的idvendor idProduct指的是USB的ID可以使用lsusb查询得到。
在你没有连接其他外设之前只要找到最后不是root hub的这一行,留意下就行(红色的就是我们插入usb的ID号)。
Bus 001 Device 019: ID 0bb4:0c02 High Tech Computer Corp. Dream / ADP1 / G1 / Magic / Tattoo (Debug)
ID 0bb4 就是idVendor ,0c02就是 idProduct
接着进入到cd /etc/udev/rules.d/下,打开(如果没有该文件,需要新建一个)51-Android.rules文件(sudo vim 51-android.rules),在这个文件中加入:
SUBSYSTEM=="usb", ATTRS{idVendor}==" 0bb4", ATTRS{idProduct}=="0c02",MODE="0666"
保存,再为51-android.rules加上权限(sudo chmod a+x 51-android.rules).
即:
xxnan@xxnan-pt:~$cd /etc/udev/rules.d/
xxnan@xxnan-pt:~$sudo gedit 51-Android.rules
添加SUBSYSTEM=="usb", ATTRS{idVendor}==" 0bb4", ATTRS{idProduct}=="0c02",MODE="0666";
保存退出51-Android.rules文件;
//运行命令,重启udev:
xxnan@xxnan-pt:~$sudo chmod a+x 51-android.rules
xxnan@xxnan-pt:~$sudo service udev restart
拔掉usb重新插上就可以了,如:
xxnan@xxnan-pt:~$ adb devices
List of devices attached
xxxxxxxxx device
如果还是不可以,需要重新插拔一次USB数据线,接着在adb devices就OK了,这样就解决了不能识别USB的问题。