How to change the Login Shell on Mac OS X from bash to zsh?

90

34

I'm trying to change the Login Shell of Mac OS X from bash to zsh. I see it is possible in Mac OS X Leopard, but for OS X Lion I can't find a way. I really hope it is possible to change the Login shell from bash to something else. I am not exactly sure where to look for.

Idlecool

Posted 2011-11-28T21:34:26.263

Reputation: 1 268

After changing shell to zsh, I still had to launch zsh manually. Logging out didn't help. I then changed zsh to the upmost login shell. Logged out and there it was. – None – 2011-12-01T16:06:30.637

1If nothing else, you can always modify the .bashrc to find and exec zsh. if [ -x /usr/local/bin/zsh ] ; then exec /usr/local/bin/zsh fi. Hint, when modifying shell startup scripts, make sure to keep a shell running and start up a new one in another window - if you break it you still have an easy place to fix it. – Dan Pritts – 2013-09-30T13:23:56.483

Answers

102

You can change user shell by the following command:

chsh -s /bin/zsh

Note: To change it for a non-standard shell, make sure its path has been added to /etc/shells file.

Spiff

Posted 2011-11-28T21:34:26.263

Reputation: 84 656

Doesn't work sometimes. @frank's answer ensures it though – oliverbarnes – 2015-07-22T17:06:28.143

/etc/shells is a read only file? doesn't let me edit it. – Awesome_girl – 2016-10-04T17:02:28.710

1@Awesome_girl By default, /etc/shells is owned, and only writable by, root (the superuser). You could, for example, use sudo vi /etc/shells to use sudo (super user do) to run the vi editor to edit /etc/shells. I just tested on my system and confirmed that it is NOT protected by System Integrity Protection, so you should be able to edit it as root without jumping through hoops to disable SIP. – Spiff – 2016-10-05T20:12:33.463

4I installed a newer version of zsh with Homebrew, which put zsh in /usr/local/bin/zsh. Unfortunately, chsh doesn't allow this, saying chsh: /usr/local/bin/zsh: non-standard shell. Daniel Beck's answer is a suitable solution in this case. – adam_0 – 2013-02-02T19:20:36.183

43If you are getting problems with non-standard shells, I think you should be able to add /usr/local/bin/zsh to /etc/shells and it should solve that problem. – Mike Meyers – 2013-02-28T10:57:59.200

13The homebrew zsh install info does actually recommend you to add it to /etc/shells:
==> Caveats To use this build of Zsh as your login shell, add it to /etc/shells.
– George – 2013-03-19T11:20:07.743

56

Funnily enough, the same method you link to in your question still works in OS X Lion through Sierra (10.12). The only difference: The preference pane is named Users & Groups instead of Accounts.

  1. Open "System Preferences" → "Users & Groups".
  2. Unless the lock icon is already unlocked, click the lock icon and authenticate yourself.
  3. Context-click on a user in the list of user names (hold down the Control key while clicking, or right-click on a right-handed two button mouse).
  4. In context menu, choose "Advanced Options…".
  5. Choose "Login shell" in the sheet that appears.

The note at the top of the "Advanced Options" screen claims you have to restart for the change to take effect, but you really just need to log out and back in again.

enter image description here

Daniel Beck

Posted 2011-11-28T21:34:26.263

Reputation: 98 421

2Confirmed still working in 10.10 Yosemite. – ecnepsnai – 2014-09-08T03:44:48.630

4right click on the username to bring up the menu containing "advanced options". That took me a couple of minutes to find. – pdwalker – 2014-12-16T12:37:24.433

@pdwalker Right, I wrote this answer on the assumption that you read the question (and clicked the link there, which describes how to do this except for the name of the preference pane). – Daniel Beck – 2014-12-16T15:30:39.863

1Why force someone to go offsite to gather all the information before being able to the answer? Hence the comment in case someone else makes the same assumption that the answer is here rather than here and there. – pdwalker – 2014-12-19T07:44:26.193

Seems to be for an outdated version of OSX. El Capitan doesn't have the context menu. – jvriesem – 2017-05-05T21:58:29.003

1@jvriesem Actually, it does. My guess is you skipped step 2. – Daniel Beck – 2017-05-05T22:00:35.097

1@DanielBeck: Sure enough! Thanks! I would have expected that the context menu would show regardless of authenticated status, but then that window would have a lock at the bottom. – jvriesem – 2017-05-05T22:10:33.370

Confirmed still works in macOS 10.13 High Sierra – Qsigma – 2017-12-31T20:49:26.847

ouhp. bummer. :| – Idlecool – 2011-12-01T19:31:27.313

1Confirmed that this works in Mountain Lion, as well as working with "non-standard shells" that you might install yourself (or have Homebrew install). – adam_0 – 2013-02-02T19:21:23.593

11

Or:

sudo dscl . change /users/$USER UserShell /bin/bash $(which zsh)

frank

Posted 2011-11-28T21:34:26.263

Reputation: 111

3Also, be careful that the path of zsh installed via homebrew is different. I do it as: sudo dscl . change /users/$USER UserShell /bin/bash $(which zsh) – metakermit – 2015-03-25T13:42:52.120

1WARNING: This will break your shell if you copy / paste it without checking the path of zsh first. Do what metakermit said instead. – radixhound – 2016-04-04T13:51:42.427

3Can you explain why this answers the question? – ChrisF – 2012-11-25T10:55:18.527

Be sure to run this after brew install zsh. – mmell – 2014-03-11T16:04:16.073

1

If anyone wondering same problem happens on macOS Sierra and following command allowed me to change shell without problems:

chpass -s /usr/local/bin/zsh

Maxim Ligus

Posted 2011-11-28T21:34:26.263

Reputation: 11

1This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. "chfn and chsh are synonyms for chpass." – DavidPostill – 2016-12-02T12:16:57.830