fastboot和adb没有使用sudo

时间:2021-07-22 16:50:29

I have a very weird issue on my Ubuntu machine when trying to run the fastboot command.

当我试图运行fastboot命令时,我的Ubuntu机器上有一个非常奇怪的问题。

When I run:

当我运行:

fastboot devices

I get

我得到

no permissions   fastboot

So I run the command with adminidtrator permissions:

因此,我使用管理员权限运行命令:

sudo fastboot devices

And then I get the result

然后得到结果

sudo: fastboot: command not found

How can this be? I have the directory in my PATH and everything works correctly without sudo.

这怎么可能?我在路径中有目录,没有sudo,一切都可以正常工作。

2 个解决方案

#1


30  

Instead of forcing permissions via sudo each time you need to run fastboot, you can permanently fix the issue:

不必在每次运行fastboot时通过sudo强制使用权限,您可以永久地修复这个问题:

  1. use lsusb to identify your device USB VendorID
  2. 使用lsusb识别你的设备USB。
  3. configure udev to set proper permissions when your device is plugged in
  4. 配置udev在设备插入时设置适当的权限
  5. profit!
  6. 利润!

As a bonus - it will be fixed for adb too.

作为一种奖励——亚行也将得到修正。

For example, in my case (for 'Megafon SP-A20i') :

例如,以我为例(“Megafon SP-A20i”):

$ fastboot devices
no permissions  fastboot
$ sudo fastboot devices
[sudo] password for kaa: 
MedfieldA9055F28    fastboot
$ 

Let's fix:

让我们解决:

First, we need to identify the device:

首先,我们需要识别设备:

a) look for usb bus number (hack: I know the device is Intel-based one)

a)查找usb总线号(hack:我知道这个设备是基于intel的)

$ fastboot -l devices
no permissions         fastboot usb:1-1.2
$ lsusb |grep 001 |grep -i intel
Bus 001 Device 044: ID 8087:09ef Intel Corp. 
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
$ 

b) look for other Intel devices:

b)寻找其他英特尔设备:

$ lsusb |grep 8087
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 044: ID 8087:09ef Intel Corp. 
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
$ 

Hubs are not smartphones definetely, so - USB vendorID we need is "8087".

集线器绝对不是智能手机,所以我们需要的是“8087”。

Second, configure udev (you must replace "idVendor" value with yours) :

第二,配置udev(必须将“idVendor”值替换为您的值):

$ sudo sh -c "echo '# Megafon SP-A20i' >> /etc/udev/rules.d/51-android.rules"
$ sudo sh -c "echo 'SUBSYSTEM==\"usb\", ATTR{idVendor}==\"8087\", MODE=\"0666\", GROUP=\"plugdev\"' >> /etc/udev/rules.d/51-android.rules"
$ sudo service udev restart
udev stop/waiting
udev  start/running, process 1821
$ 

Third, re-plug your device to allow udev to perform it's magic.

第三,重新插入设备,让udev发挥它的魔力。

Final check:

最后的检查:

$ fastboot -l devices
MedfieldA9055F28       fastboot usb:1-1.2
$ adb devices
List of devices attached 

$ fastboot reboot
rebooting...

finished. total time: 0.253s
$ sleep 90
$ adb devices
List of devices attached 
MedfieldA9055F28    device

$ 

Voila!

瞧!

#2


9  

You can use

您可以使用

sudo $(which fastboot) devices

sudo(fastboot美元)设备

#1


30  

Instead of forcing permissions via sudo each time you need to run fastboot, you can permanently fix the issue:

不必在每次运行fastboot时通过sudo强制使用权限,您可以永久地修复这个问题:

  1. use lsusb to identify your device USB VendorID
  2. 使用lsusb识别你的设备USB。
  3. configure udev to set proper permissions when your device is plugged in
  4. 配置udev在设备插入时设置适当的权限
  5. profit!
  6. 利润!

As a bonus - it will be fixed for adb too.

作为一种奖励——亚行也将得到修正。

For example, in my case (for 'Megafon SP-A20i') :

例如,以我为例(“Megafon SP-A20i”):

$ fastboot devices
no permissions  fastboot
$ sudo fastboot devices
[sudo] password for kaa: 
MedfieldA9055F28    fastboot
$ 

Let's fix:

让我们解决:

First, we need to identify the device:

首先,我们需要识别设备:

a) look for usb bus number (hack: I know the device is Intel-based one)

a)查找usb总线号(hack:我知道这个设备是基于intel的)

$ fastboot -l devices
no permissions         fastboot usb:1-1.2
$ lsusb |grep 001 |grep -i intel
Bus 001 Device 044: ID 8087:09ef Intel Corp. 
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
$ 

b) look for other Intel devices:

b)寻找其他英特尔设备:

$ lsusb |grep 8087
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 044: ID 8087:09ef Intel Corp. 
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
$ 

Hubs are not smartphones definetely, so - USB vendorID we need is "8087".

集线器绝对不是智能手机,所以我们需要的是“8087”。

Second, configure udev (you must replace "idVendor" value with yours) :

第二,配置udev(必须将“idVendor”值替换为您的值):

$ sudo sh -c "echo '# Megafon SP-A20i' >> /etc/udev/rules.d/51-android.rules"
$ sudo sh -c "echo 'SUBSYSTEM==\"usb\", ATTR{idVendor}==\"8087\", MODE=\"0666\", GROUP=\"plugdev\"' >> /etc/udev/rules.d/51-android.rules"
$ sudo service udev restart
udev stop/waiting
udev  start/running, process 1821
$ 

Third, re-plug your device to allow udev to perform it's magic.

第三,重新插入设备,让udev发挥它的魔力。

Final check:

最后的检查:

$ fastboot -l devices
MedfieldA9055F28       fastboot usb:1-1.2
$ adb devices
List of devices attached 

$ fastboot reboot
rebooting...

finished. total time: 0.253s
$ sleep 90
$ adb devices
List of devices attached 
MedfieldA9055F28    device

$ 

Voila!

瞧!

#2


9  

You can use

您可以使用

sudo $(which fastboot) devices

sudo(fastboot美元)设备