Bash shell android phone
Android: Force Terminal Emulator to Open the BASH Shell as Root
Important! This article assumes that your phone is rooted. If you don’t know what that is or how to do it, this article won’t be able to help you. If your phone isn’t rooted, this won’t work.
I love my Android phone, but the root side of it still has some quirks. The default shell, for example, is pretty bare-bones. Fortunately, there are ROMs out there like CyanogenMod that help with that side of things by providing little extras like, for example, the BASH shell. BASH is incredibly handy on an Android phone as the default shell doesn’t allow you to scroll back through your command history using the track ball.
So while BASH is included in some ROMs, it’s not the default shell. Typically, I’ve been using ConnectBot (available on the Android Market) which works well, however I’d usually end up starting out every session like this:
su -c bash
It’s only one line, but really, it’s annoying to have to type it out every time. I’m in the IT field, so my nature is to be lazy and automate everything. Enter Terminal Emulator.
Available for free from the Android Market, Terminal Emulator is very basic. It doesn’t allow you to SSH to remote systems or anything like that – instead, it just immediately opens a local shell. As an added bonus, the preferences let you specify the Command Line to the shell executable.
I thought this was my answer. I set the Command Line preference to “/system/xbin/bash -” (the location on CyanogenMod 5.x.x — this may differ depending on your ROM. Make sure the path is correct before hand, as if you set it incorrectly it’s nearly impossible to get Terminal Emulator back up and running) and re-launched it.
Success! I was in the BASH shell! However, I wasn’t root, and this did cause a problem. As soon as I typed su to become root, my shell was changed back to the default one. After doing a little more digging, though, I found my solution.
In the Terminal Emulator preferences, there’s another option for Initial Command – Terminal Emulator will execute this immediately on open. So, I inserted the line I was using in ConnectBot (su -c bash) and voilà! Terminal Emulator now immediately opens with a BASH shell as root.
The TL;DR version: Install Terminal Emulator from the Android Market, open it, hit the Menu button, then Preferences. Tap Initial Command and enter “su -c bash” — now it will always open with BASH running as root.
Extra Note: If you are using an Android phone without a physical keyboard, simply hold the Menu button on your phone for a few seconds in Terminal Emulator to force the virtual keyboard to appear.
UPDATE: As it turns out, you can do this in ConnectBot as well. Tap-and-hold on the local connection, then choose ‘Edit Host’ and ‘Post-login automation’. Note that if you do this, though, ConnectBot will enter the command, but you still have to press enter to active it.