• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [GUIDE] Full bash shell with nano, tab completion, and color over ssh

jmxp69

Well-Known Member
Feb 26, 2010
208
121
hopke.net
I cobbled all of this together from various places on the web, but I think the credit for the binaries goes to Paul @ MoDaCo.

Nandroid before going any further!

Files you'll need:

QuickSSHD (Download this from the Market. $1.50). I'm just going to assume if you're still reading, you know what this is for and how to use it. It's braindead simple. I think dropbear can be installed and configured manually, but for the $1.50...meh.

The rest are zipped up here: terminfo.zip, nano, bash, profile**

Unzip bashnano.zip onto your SDCard.

From adb shell:

Install Terminfo:
cp -r /sdcard/terminfo /system/etc

Setup Bash:
cp /sdcard/bash /system/bin/bash_new
mv /system/bin/sh /system/bin/sh.old
ln -s /system/bin/bash_new /system/bin/sh
cp /sdcard/profile /etc

Setup Nano:
cp /sdcard/nano /system/bin


I'm not sure if this setup will have any impact on sh scripts being used in the various ROMs, so use this at your own risk.

This will give you full bash over adb, but I haven't figured out where profile goes to add terminal/color et al. for adb.

Anyway, hope y'all find it useful.

**profile reflects a few personal choices for aliases and colors, but you can edit to your personal taste.
 
Very awesome! I only wish this was in apk package form lol
But perhaps that isn't possible because of permissions.


I didn't need QuickSSHD. Any regular terminal should work, and many are $0 free on the market. I recommend "Terminal Emulator" or "ConnectBot".

Also, a few steps that appear to be missing:
1. Before attempting to write to /system/bin, you need to remount it as writable
./adb remount (through USB)
OR
mount -o rw,remount /dev/block/mtdblock1 /system (as root on terminal)
2. chmod 755 /system/bin/bash_new (make it executable)
3. chmod 755 /system/bin/nano (make it executable)


These programs work on my rooted motorola cliq, with a few exceptions. I actually had to store the files (bash and nano) in /data/ (mtdblock2), and symlink to them from /system/bin, because there wasn't enough free space on the root partition.

My steps were similar to this:
1. Through USB run ./adb remount
2. Login to android terminal as root (Terminal Emulator)
3. Run these commands
cp /sdcard/bashnano/profile /etc
cp /sdcard/bashnano/bash /data
cp /sdcard/bashnano/nano /data
chmod 755 /data/bash
chmod 755 /data/nano
cd /system/bin/
mv sh sh.old
ln -s /data/bash sh
ln -s /data/bash bash
ln -s /data/nano nano


Using BASH special keys:
Control (Ctrl) key = Wheel button
Escape key (esc) = Ctrl + 1 + 2 (comes in handy big time if using vi)
Go to beginning of line = Ctrl +a
Go to end of line = Ctrl + e
Tab completion = Ctrl + i
The commandline redirection ">" = Shift + Alt + l
The commandline redirection "<" = Shift + Alt + k
The pipe character "|" = Shift + Alt + a
Cut = Ctrl + w
Paste = Ctrl + y
Reverse search previous commands = Ctrl + r
Break reverse search = Ctrl + g
Reverse slash "\" = Ctrl + Shift + n
Carrot key "^" = Ctrl + Shift + j

Anyone Please write in if you know how to input any other special characters, such as "~" or "[" or "]".


I recommend Remounting your /system read-write and downloading BUSYBOX from the market Before installing bashnano. Backup your system.
 
  • Like
Reactions: ninadchaudhari
Upvote 0
Exactly what is this gonna let us do on/to our phones?
ROOT?
I just realized that jmxp69 did not state that the phone needs to be rooted before you can install these programs. I'm pretty sure that your phone must be ROOTED first.

I use Ubuntu Linux as my desktop operating system. On my desktop, I use the bash shell almost everyday. With the Bash shell, I can perform operations that are impossible with graphical programs (such as batch operations, appending to files, changing owners/groups/permissions, remounting/reformating file system, automated/timed/looped scripts, much more).

Nano is a popular text editor that runs in the terminal. It is useful for simply editing text files or creating bash scripts.
 
Upvote 0
I just spent an hour doing this before I decided to google it and find it's been done! Though I have a problem, I have to retype 'export TERMINFO=/etc/terminfo' each time I run a shell to get nano to run. I have tried to script this command but it seems ONLY typing it manually will work. Any ideas how to fix that?
 
Upvote 0
I just spent an hour doing this before I decided to google it and find it's been done! Though I have a problem, I have to retype 'export TERMINFO=/etc/terminfo' each time I run a shell to get nano to run. I have tried to script this command but it seems ONLY typing it manually will work. Any ideas how to fix that?
Go into your terminal app preferences and insert ";export TERMINFO=/etc/terminfo;" in the initial/initialization command.
 
Upvote 0
You can also do it the /system/etc/mkshrc file.

I used Vi iMproved Touch and Hackers Keyboard here, these settings also work for touchqode.

uploadfromtaptalk1352534285510.jpg

For bash, I add a line to source my own /sdcard/bashrc to the initialization for Terminal Emulator.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones