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
adb存在于/ home / lubuntu / Tools / android-sdk-linux / platform-tools中
Then I executed adb start-server
:
然后我执行了adb start-server:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Then sudo adb install test.apk
然后sudo adb安装test.apk
sudo: adb: command not found
I have added adb in the environment variable $PATH, but sudo couldn't find it. Why?
我在环境变量$ PATH中添加了adb,但是sudo找不到它。为什么?
5 个解决方案
#1
6
sudo
means you're switching to root, and that does not necessarily mean that your environment comes along. That could be dangerous.
sudo意味着你要切换到root,这并不一定意味着你的环境出现了。那可能很危险。
At your risk, add the -E
option to inherit the calling environment.
冒风险,添加-E选项以继承调用环境。
#2
5
The problem is the PATH var is set for that user, and root don't have the aditional PATH entry, so it can't found the program.
问题是为该用户设置了PATH var,而root没有aditional PATH条目,因此无法找到该程序。
You should setup adb for root too:
你也应该为root设置adb:
adb Environmental Variables
adb环境变量
Open ~/.bashrc
and add the following to the very bottom
打开〜/ .bashrc并将以下内容添加到最底层
export PATH=${PATH}:<sdk>/tools:<sdk>/platform-tools
Change <sdk>
to the actual path. ie /home/user/android-sdk-linux
Close and re-open your terminal to refresh variables.
将
from adb setup
来自adb设置
If doesn't work, make symbolic links from adb and other binaries to /usr/local/bin
如果不起作用,请将adb和其他二进制文件的符号链接创建到/ usr / local / bin
#3
2
Since you are running adb as root in the second example, adb would also have to be on root's path.
由于您在第二个示例中以root身份运行adb,因此adb也必须位于root的路径上。
#4
2
completely agree with answer of @unwind.
You must not do this using "sudo".
Give it a try without sudo and i guess it would work for you.
Also, you should add the path to folder named "tools" present in the sdk, though its not connected with your problem, but a suggestion.
完全赞同@unwind的回答。你不能使用“sudo”这样做。尝试没有sudo尝试,我想它会对你有用。此外,您应该将路径添加到sdk中存在的名为“tools”的文件夹中,尽管它与您的问题无关,但建议。
#5
2
Completely agree.
The problem was the Android Debug Bridge (adb) command line tool that was not linked to the path. After setting it in the path, it worked for me.
问题是没有链接到路径的Android Debug Bridge(adb)命令行工具。在路径中设置后,它对我有用。
$ gedit ~/.bashrc
set the path as follows in the .bashrc
在.bashrc中设置如下路径
export PATH=${PATH}:~/adt-bundle/tools
export PATH=${PATH}:~/adt-bundle/platform-tools
#1
6
sudo
means you're switching to root, and that does not necessarily mean that your environment comes along. That could be dangerous.
sudo意味着你要切换到root,这并不一定意味着你的环境出现了。那可能很危险。
At your risk, add the -E
option to inherit the calling environment.
冒风险,添加-E选项以继承调用环境。
#2
5
The problem is the PATH var is set for that user, and root don't have the aditional PATH entry, so it can't found the program.
问题是为该用户设置了PATH var,而root没有aditional PATH条目,因此无法找到该程序。
You should setup adb for root too:
你也应该为root设置adb:
adb Environmental Variables
adb环境变量
Open ~/.bashrc
and add the following to the very bottom
打开〜/ .bashrc并将以下内容添加到最底层
export PATH=${PATH}:<sdk>/tools:<sdk>/platform-tools
Change <sdk>
to the actual path. ie /home/user/android-sdk-linux
Close and re-open your terminal to refresh variables.
将
from adb setup
来自adb设置
If doesn't work, make symbolic links from adb and other binaries to /usr/local/bin
如果不起作用,请将adb和其他二进制文件的符号链接创建到/ usr / local / bin
#3
2
Since you are running adb as root in the second example, adb would also have to be on root's path.
由于您在第二个示例中以root身份运行adb,因此adb也必须位于root的路径上。
#4
2
completely agree with answer of @unwind.
You must not do this using "sudo".
Give it a try without sudo and i guess it would work for you.
Also, you should add the path to folder named "tools" present in the sdk, though its not connected with your problem, but a suggestion.
完全赞同@unwind的回答。你不能使用“sudo”这样做。尝试没有sudo尝试,我想它会对你有用。此外,您应该将路径添加到sdk中存在的名为“tools”的文件夹中,尽管它与您的问题无关,但建议。
#5
2
Completely agree.
The problem was the Android Debug Bridge (adb) command line tool that was not linked to the path. After setting it in the path, it worked for me.
问题是没有链接到路径的Android Debug Bridge(adb)命令行工具。在路径中设置后,它对我有用。
$ gedit ~/.bashrc
set the path as follows in the .bashrc
在.bashrc中设置如下路径
export PATH=${PATH}:~/adt-bundle/tools
export PATH=${PATH}:~/adt-bundle/platform-tools