2

I'm currently using adb terminal to access my database files. However, I can only access the terminal using this:

./adb shell

I would like to switch from sh to bash as it is much more convenient for some shortcuts. How do I do that?

1
  • 2
    Do you have bash binary on your Android device? Commented Dec 29, 2017 at 8:28

2 Answers 2

1

i dont think adb have bash options , if you type adb help , you will see options for shell and not for 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

May be if you can share, what specific difficulties you are facing in running the shortcut or command

However if you still wanted to use adb with bash , you can have a look on below link

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

Sign up to request clarification or add additional context in comments.

1 Comment

That post is extremely outdated and obsolete, and it is totally invalid now for modern Android versions.
1

Answered here

Found the proper & simple way from a Linux box:

adb shell -t bash -i

You logon directly via in interactive way.

To not having to remember this command all the times, I personally use an alias, simply add this to your ~/.bashrc on Linux box:

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

Then all is configured, simply run

adb_shell

and enjoy all bash features like tab completion and anything. \o/

2 Comments

This only works if the bash executable on the Android device is installed somewhere outside of Termux. On my Android 14 and Android 15 devices, the only bash executable is installed under Termux and is inaccessible via "adb shell" unless "su -" is run first. Needing to run as root simply to invoke bash under "adb shell" is totally undesirable for me and lots of other Android users.
You can simply get a statically linked bash and push it to /data/local/tmp and use that without root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.