+ Reply
Results 1 to 9 of 9

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: bin/bash Login HOW-TO

is a discussion within the

File Mods

forums, a part of the

iPhone Modding

section;
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
...
  1. #1
    Green Apple mrengles's Avatar
    Join Date
    Aug 2007
    Posts
    51
    Thanks
    3
    Thanked 8 Times in 6 Posts

    Default bin/bash Login HOW-TO
    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)

    PATH="/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin"
    export PATH

    TERM="vt102"
    export TERM

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

    /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:

    exit
    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; 08-23-2007 at 12:39 PM.
    Gratitude,
    mrengles

  2. The Following 3 Users Say Thank You to mrengles For This Useful Post:

    adm (09-01-2007), hillie (09-06-2007), scr4p (09-19-2007)

  3. #2
    What's Jailbreak?
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default No .profile method
    you can skip the "exit" command in the .profile if you just do this in /etc/profile:

    exec /bin/bash --rcfile ~/.bash_profile

  4. #3
    Green Apple mrengles's Avatar
    Join Date
    Aug 2007
    Posts
    51
    Thanks
    3
    Thanked 8 Times in 6 Posts

    Yes you can however your zch shell will continue to run after exiting terminal. This just tells sh to quit on exit of terminal.
    Gratitude,
    mrengles

  5. #4
    adm
    adm is offline
    Green Apple
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    14
    Thanked 4 Times in 4 Posts

    Quote Originally Posted by mrengles View Post
    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.
    Thanks.

  6. #5
    Green Apple
    Join Date
    Jun 2007
    Location
    Baltimore
    Posts
    78
    Thanks
    4
    Thanked 3 Times in 2 Posts

    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.

  7. #6
    What's Jailbreak?
    Join Date
    Sep 2007
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thanks for the tip; how would you get it to set tcsh as your default?

  8. #7
    Green Apple
    Join Date
    Jun 2007
    Location
    Baltimore
    Posts
    78
    Thanks
    4
    Thanked 3 Times in 2 Posts

    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?

  9. #8
    What's Jailbreak?
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 1 Time in 1 Post
    there is a rebuilt version if you look at it on fiveforty dot net, command recall works, and it does not freeze.

  10. The Following User Says Thank You to sins07 For This Useful Post:

    hillie (09-21-2007)

  11. #9
    Green Apple
    Join Date
    Jun 2007
    Location
    Baltimore
    Posts
    78
    Thanks
    4
    Thanked 3 Times in 2 Posts

    does it work when called from your true login (/etc/master.passwd)?

    btw. sins07 thanked ! (more ppl should use the thank button on here =)

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts