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


Last Updated:

  1. jmxp69

    jmxp69 Well-Known Member This Topic's Starter

    Joined:
    Feb 26, 2010
    Messages:
    208
    Likes Received:
    121
    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.
     

    Advertisement
    ocnbrze and ninadchaudhari like this.
  2. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    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.
     
    ninadchaudhari likes this.
  3. cabbie

    cabbie Well-Known Member

    Joined:
    Mar 23, 2010
    Messages:
    1,344
    Likes Received:
    553
    yea...i feel dumb. what is the objective of all this?
     
  4. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    Bash shell does not appear to be recognizing the file /etc/profile

    Not 100% sure
     
  5. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    The objective is to install the Bash shell and Nano text editor. These are for use in the commandline/terminal.
     
  6. Hazy

    Hazy Well-Known Member

    Joined:
    Aug 10, 2010
    Messages:
    82
    Likes Received:
    6
    Exactly what is this gonna let us do on/to our phones?
     
  7. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    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.
     
  8. laredo7mm

    laredo7mm Well-Known Member

    Joined:
    Jun 2, 2010
    Messages:
    379
    Likes Received:
    77
    Nothing for the every day user.

    It is a different story if you are a Dev or are familiar with command line stuff.
     
  9. StuartRothrock

    StuartRothrock New Member

    Joined:
    Oct 13, 2010
    Messages:
    1
    Likes Received:
    0
    THANKS FOR THE NICE INFO!!

    I didnt rename bash
    I put profile in /system/etc
    created /system/etc/shells with /system/bin/bash
    and sshd uses bash automatically

    wasnt too crazy renaming /system/bin/sh...
     
  10. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    Uploading another copy of the zip file incase the original server ever goes down.
     

    Attached Files:

  11. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    Also there is a free editor and screen keyboard on the market named "touchqode" that is very useful for typing in programming/scripting code and special characters. java php perl python c++ etc

    It supports ftp, file syncing, syntax highlighting and more.

    market://details?id=com.touchqode.editor
    http://www.touchqode.com

     
  12. tozhan

    tozhan New Member

    Joined:
    Feb 6, 2012
    Messages:
    1
    Likes Received:
    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?
     
  13. Sepero

    Sepero Linux Guru

    Joined:
    Aug 26, 2010
    Messages:
    962
    Likes Received:
    564
    Go into your terminal app preferences and insert ";export TERMINFO=/etc/terminfo;" in the initial/initialization command.
     
    EarlyMon and ocnbrze like this.
  14. EarlyMon

    EarlyMon The PearlyMon Moderator

    Joined:
    Jun 10, 2010
    Messages:
    57,614
    Likes Received:
    70,271
    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.
     
    9to5cynic, lunatic59 and ocnbrze like this.

Share This Page

Loading...