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
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…
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.passwdfile so both themobileandrootusers on the iPhone default to using zsh instead of bash. You could also just typezshon the command line to launch it, but it’s far more useful when set as the default shell.One Trackback
[...] 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 [...]