如何在adb(android)中使用Bash而不是Shell?

时间:2017-12-29 06:14:25

标签: android bash adb sh

我目前正在使用adb终端来访问我的数据库文件。但是,我只能使用以下方式访问终端:

./adb shell

我想从sh切换到bash,因为它对某些快捷方式更方便。我该怎么做?

2 个答案:

答案 0 :(得分:0)

我不认为adb有bash选项,如果你输入 adb help ,你会看到shell的选项而不是bash的选项

shell:
 shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]
     run remote shell command (interactive shell if no command given)
     -e: choose escape character, or "none"; default '~'
     -n: don't read from stdin
     -T: disable PTY allocation
     -t: force PTY allocation
     -x: disable remote exit codes and stdout/stderr separation
 emu COMMAND              run emulator console command

可能是您可以分享,您在运行快捷方式或命令时遇到的具体困难

但是,如果您仍然希望将adb与bash一起使用,可以查看以下链接

https://android.stackexchange.com/questions/19315/how-to-set-bash-as-default-shell

答案 1 :(得分:0)

回答here

从 Linux 机器中找到了正确且简单的方法:

adb shell -t bash -i

您以交互方式直接通过 登录。

为了不必一直记住这个命令,我个人 使用别名,只需将其添加到您在 Linux 机器上的 ~/.bashrc 中:

alias adb_shell='adb shell -t bash -i'
source ~/.bashrc

那么一切都配置好了,直接运行

adb_shell

并享受所有 bash 功能,例如 Tab 补全等。 \o/