Ilias in adb shell non-interactive mode

Hi I need to run things as adb shell <command>

When I test everything inside the adb shell it works because I was able to set some aliases in .bashrc

. However, when I do adb shell <command>

, nothing works because it is .bashrc

not used at startup adb shell <command>

because it is in non-interactive mode.

How can I get around this? Can I have adb push

some files in the filesystem so that the alias will be there when it adb shell



source to share

3 answers

If your Android device is installed, you can add your aliases to adb shell

the file /system/etc/mkshrc




One way to do this is to issue multiple shell commands in a single ADB command. You can simply separate them with semicolons, like so:

adb shell "alias foo bar; export MY_VARIABLE=/path/to/somewhere; my_executable "

You can run yours .bashrc

this way, this way:

adb shell "source/path/to/.bashrc; my_executable"



You can write a bash script that sets up aliases and then executes your shell:

. $HOME/.bashrc
adb shell $@




All Articles