Running zsh on the iPhone

I jailbroke my iPhone 3G as soon as the iPhone Dev Team had posted their tool to do so, and ever since, I’ve been screwing about with the command line. There’s something deeply appealing to my inner nerd about having Unix on my phone, and recreational command line hacking is more fun for me than many of the games available for iPhone.

The one thing missing on my journey to mobile nerdvana was zsh, my favorite shell. Cydia had a zsh package available as soon as Pwnage Tool 2.0 came out, and I promptly installed it. Unfortunately, though I was able to run zsh from the command line, I couldn’t figure out how to set it as the default login shell.

Well, a bit of googling later, and I found out that on the iPhone (and possibly Mac OS X, whence iPhone derives much of its unixy goodness) editing /etc/passwd won’t do the trick. In fact, there’s a big fat comment at the head of /etc/passwd that informs you that editing it won’t be particularly useful:

How then to set up default shells? Edit /etc/master.passwd, of course. iPhone uses this file as its authoritative user database, and changes to the login shell in this file work quite well. Change /bin/sh to /bin/zsh at the ends of the root and mobile lines, and you’re good to go. Here’s /etc/master.passwd after I’ve modified it for zsh goodness:

Note that you must be logged on as root to edit /etc/master.passwd.

2 Comments

  1. Moi
    Posted September 17, 2008 at 2:12 pm | Permalink

    Hi,

    I just installed zsh via cydia on my iphone 3G, but how could I launch it ???
    No shortcut on the springboard…

    Thx for your help…

  2. Posted September 18, 2008 at 6:31 pm | Permalink

    zsh is a command line program only, and as such, it has no Springboard icon. Instead, you need to run it on the iPhone’s command line. I use Mobile Terminal (available on Cydia), which is a great on-the-phone way of getting a terminal window. You can also get a command line for the iPhone by installing OpenSSH (also on Cydia), then connecting to your iPhone with a terminal program on a computer via ssh.

    In the post above, I detail how I set up the master.passwd file so both the mobile and root users on the iPhone default to using zsh instead of bash. You could also just type zsh on the command line to launch it, but it’s far more useful when set as the default shell.

One Trackback

  1. By Recent Links Tagged With "zsh" - JabberTags on October 27, 2008 at 7:49 pm

    [...] public links >> zsh Running zsh on the iPhone Saved by Jemeela on Sun 26-10-2008 Fancy Globbing With Zsh On Linux and Unix Saved by SakuraNeji [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*