Android Debug Bridge (adb) command-line tool exists on $ PATH but "command not found" on Linux

sudo echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/lubuntu/Tools/android-sdk-linux/platform-tools 

adb exists in /home/lubuntu/Tools/android-sdk-linux/platform-tools

Then I executed adb start-server :

 * daemon not running. starting it now on port 5037 * * daemon started successfully * 

Then sudo adb install test.apk

 sudo: adb: command not found 

I added adb to the $ PATH environment variable, but sudo could not find it. Why?

+6
source share
5 answers

sudo means you switch to root, and that doesn't necessarily mean your environment is coming. It may be dangerous.

At your own risk, add the -E option to inherit the calling environment.

+6
source

The problem is that the PATH var parameter is set for this user, and root does not have an additional PATH entry, so he cannot find the program.

You must also configure adb for root:

adb Environmental Variables

Open ~/.bashrc and add the following to the very bottom

 export PATH=${PATH}:<sdk>/tools:<sdk>/platform-tools 

Change <sdk> to the actual path. those. /home/user/android-sdk-linux Close and reopen your terminal to update the variables.

from adb setup

If this does not work, make symbolic links from adb and other binaries to / usr / local / bin

+5
source

Since in the second example you are using adb as root, adb should also be on the root path.

+2
source

totally agree with @unwind's answer.
You should not do this with "sudo".
Try it without sudo and I think this will work for you. you must add the path to the folder named "tools" present in sdk, although it is not related to your problem, but a suggestion.

+2
source

I completely agree.

The problem was the Android Debug Bridge (adb) command-line tool, which was not associated with this path. After it was installed on the way, it worked for me.

 $ gedit ~/.bashrc 

set the path as follows in .bashrc

 export PATH=${PATH}:~/adt-bundle/tools export PATH=${PATH}:~/adt-bundle/platform-tools 
+2
source

Source: https://habr.com/ru/post/909266/


All Articles