Search code examples
androidlinuxadbsudo

Android Debug Bridge (adb) command line tool exists in $PATH, but "command not found" in 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 have added adb in the environment variable $PATH, but sudo couldn't find it. Why?


Solution

  • sudo means you're switching to root, and that does not necessarily mean that your environment comes along. That could be dangerous.

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