How do I change a users default shell in OSX?

33

8

What is the correct OSX way of changing a users default shell? When I googled for it I found several references to an application called NetInfo Manager but I couldn't find it on my system. There were also references to a command line version called niutil which I didn't find either.

David Holm

Posted 2009-06-06T08:09:41.117

Reputation: 771

possible duplicate of How do I set my shell in Mac OS X?

– Daniel Beck – 2012-01-18T09:22:10.890

Answers

52

for <=10.4 - netinfo manager, /users/whoever/shell

for >=10.5

  1. Go to System Preferences -> Accounts
  2. Click the lock icon to unlock the preference pane
  3. Right-click (or control-click) on user and select "advanced options"
  4. Edit login shell field

Chopper3

Posted 2009-06-06T08:09:41.117

Reputation: 2 547

2It doesn't work anymore on el Capitan? – MarcusJ – 2016-08-06T15:29:38.860

True, this is the issue with this kind of thing, 7 years down the line and things have changed - why not do some research yourself, add and answer and it'll get upvoted, that's how things work, better than just sniping little answers – Chopper3 – 2016-08-06T22:50:25.023

Please make sure your shell is added to /etc/shells first. – ryenus – 2018-11-05T12:10:37.583

5Wow, after 8 years of using OS X I didn't know about control clicking in the users prefs: I guess this was added in 10.5 though as you pointed out. +1 – jkp – 2010-11-13T16:03:57.513

1Control-Click is stunnning! – Eonil – 2011-02-24T02:01:04.283

1Lifesaver after moving my account's shell out of the PATH... couldn't start Terminal to fix via command line! – davemyron – 2012-10-31T07:58:52.133

33

sudo chsh -s /path/to/shell username

where shell is the one you want for that user. sudo is not needed if you know username's password.

man chsh

for more examples.

churnd

Posted 2009-06-06T08:09:41.117

Reputation: 4 228

works too for root for su, which isn't visible in control panel. I think? – Chris F Carroll – 2013-03-19T15:55:52.197

4You can also run just chsh and change the shell field. If you get an error like chsh: /usr/local/bin/bash: non-standard shell, add /usr/local/bin/bash to /etc/shells. – Lri – 2013-03-19T19:15:08.273

3Maybe something changed in 10.9, but this command now throws a usage message. It seems the correct syntax is now chsh -s /path/to/shell username – Matthematics – 2014-01-24T23:17:13.063

9

NetInfo has been replaced by Directory Services (dscl) and it can be noted the default shell for Mac OS X since 10.3 has been bash. Prior to that it was tcsh.

If you need to do this from the command line (eg. for pushing via ARD or remotely via SSH) you can run:

sudo dscl localhost -change /Local/Default/Users/USERNAME shell OLD_SHELL NEW_SHELL
#In Use:
sudo dscl localhost -change /Local/Default/Users/chealion shell /bin/bash /bin/zsh

If you're not sure of the current shell you can run:

sudo dscl localhost -read /Local/Default/Users/USERNAME shell

If the user is not a local user the path will simply change and if necessary you would change localhost to the name of your Open Directory Server. (Assuming it runs 10.5).

The info is stored in .plists (xml) in /private/var/db/dslocal/ - you don't want to edit the plist files by hand however.

Chealion

Posted 2009-06-06T08:09:41.117

Reputation: 22 932

7

For 10.10:

not shell but UserShell:

sudo dscl localhost -change /Local/Default/Users/USERNAME UserShell /bin/bash /bin/ksh

willem

Posted 2009-06-06T08:09:41.117

Reputation: 71