How do I set my shell in Mac OS X?
Solution 1:
Use the chsh
utility like so:
chsh -s bash
Apple has changed chsh
a bit on Mac OS X compared to the chsh
you'd see in Linux for example. You can read up on theirs in the chsh Mac OS X Man Page.
Solution 2:
Note that you will only be allowed to change to a shell listed in /etc/shells
. This is normally fine, but it means that if you want to install Bash 4 (from Homebrew, MacPorts, or compiling your own), you need to add a line to /etc/shells
. (I ran into this a few weeks ago, and figured it might help others to know...)
Edit: Tim Smith points out that you can get around the /etc/shells
limitation if you run chsh
as root via sudo
. E.g. sudo chsh -s /usr/local/bin/my_shell $USER
will work, even if my_shell
is not listed in /etc/shells
. I prefer to edit /etc/shells
, but in the end, it's one use of sudo
either way since you can't edit /etc/shells
as a regular user. So perhaps six of one, half dozen of the other.
Solution 3:
To do this using the Mac OS X GUI:
- Open “System Preferences.”
- Open the “Accounts”/“Users & Groups” preference pane and unlock the preference pane if applicable.
- On the user you wish to change the shell, control+click or right click on the user and choose “Advanced Options…”
- Where it says “Login Shell:” change this to the shell you wish to use.
Of note, this location is where you can change your home directory, UUID, User ID, Group ID, and short name if you're uncomfortable with the Terminal. There is a similar question located here as well.
Solution 4:
Using the answers above I was getting an error message:
$ chsh -s zsh
Changing shell for myuser.
Password for myuser:
chsh: zsh: non-standard shell
To work around this:
sudo chsh -s zsh $(whoami)
whoami
in a subshell is to change the shell for your user, not the root.
One more thing if you're using homebrew. When you run commands as root (using sudo
), zsh points to /bin/zsh, which comes with OSX and might be outdated. To use the up to date one that is installed via homebrew, use the following:
sudo chsh -s $(which zsh) $(whoami)