User Tag List

  1. mrengles's Avatar
    Why use /bin/bash and not the default /bin/sh (zsh Shell)...

    Because.... Bash is the shell, or command language interpreter, that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.

    Mac OS X uses it
    performs better then zsh on iphone

    The improvements offered by BASH include:

    Command line editing
    Unlimited size command history
    Job Control
    Shell Functions and Aliases
    Indexed arrays of unlimited size
    Integer arithmetic in any base from two to sixty-four

    How do I get started?

    First off you will need to have SSH or an SFTP server running on the iPhone. I will not go into the details on howto install them or use them. That info is all over the net... hint google search "iphone ssh" or look at the modmyi guides.

    1. connect to your iPhone via ssh or sftp.
    2. open /private/etc/profile
    3. add this text "/bin/bash --rcfile ~/.bash_profile"

    your /private/etc/profile should look like this:

    # System-wide .profile for sh(1)

    export PATH

    export TERM

    if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc

    /bin/bash --rcfile ~/.bash_profile
    4. goto /private/var/root
    5. create a file called .profile
    6. add this text "exit"

    your /private/var/root/.profile should look like this:

    7. goto /private/var/root
    8. create a file called .bash_profile
    9. add this text "echo "Welcome to Darwin!"
    PS1="iPhone$ ""

    your /private/var/root/.bash_profile should look like this:

    echo "Welcome to Darwin!"
    PS1="iPhone$ "

    10. Restart iPhone.... and enjoy /bin/bash

    Note if you are using a custom .profile move all the info to .bash_profile so it will load with bash.

    This is a work around because editing the master.passwd file to run /bin/bash crashes the iPhone. =(
    Last edited by mrengles; 2007-08-23 at 07:39 PM.
    2007-08-23 07:25 PM
  2. tamstoker's Avatar
    you can skip the "exit" command in the .profile if you just do this in /etc/profile:

    exec /bin/bash --rcfile ~/.bash_profile
    2007-08-27 01:59 AM
  3. mrengles's Avatar
    Yes you can however your zch shell will continue to run after exiting terminal. This just tells sh to quit on exit of terminal.
    2007-08-27 04:56 PM
  4. adm's Avatar
    This is a work around because editing the master.passwd file to run /bin/bash crashes the iPhone. =(
    Indeed it does. I had to restore thrice times before I figured out why I kept crashing.

    Good tutorial for others.
    2007-09-01 03:43 PM
  5. hillie's Avatar
    I tried editing the /etc/master.passwd file too but I kept the one ssh session open while I tested it, to avoid a possible lockout.

    If you do get locked out though, there is possibly another way, you could always use WinSCP or scp to pull down the /etc/master.passwd file, fix it and then put it back up.. because sftp (which is what WinSCP/scp uses) doesn't run the shell but actually goes through an sftp filter/tunnel/whatever.

    Also it would be wise to comment out the exit in the .profile first and make sure it works, and THEN uncomment it.

    it's a really bad idea to have 'exit' in your profile because of the likely hood of getting locked out, but if you make sure everything works the way it should you can then uncomment it.
    2007-09-06 09:47 PM
  6. chdunk's Avatar
    Thanks for the tip; how would you get it to set tcsh as your default?
    2007-09-10 06:44 PM
  7. hillie's Avatar
    I've changed my shell back to /bin/sh after getting sick of my phone freezing up due to /bin/bash which seems somewhat unstable on the iPhone.

    It should be fine to run scripts but as a shell it's very annoying to constantly have to reboot the phone just because I want bash.

    /bin/sh works better than bash too because the command history works, unlike it bash where it just beeps at you (it's SUPPOSED to be the same but it isn't)..

    has anyone else noticed bash freezing their phone?
    2007-09-21 04:42 AM
  8. sins07's Avatar
    there is a rebuilt version if you look at it on fiveforty dot net, command recall works, and it does not freeze.
    2007-09-21 05:11 AM
  9. hillie's Avatar
    does it work when called from your true login (/etc/master.passwd)?

    btw. sins07 thanked ! (more ppl should use the thank button on here =)
    2007-09-21 01:44 PM