Add or change user database information, change default shell.
Syntax chsh [-l location] [-u authname] [-s newshell] [user]
-l location If not specified, chpass will perform a search for the user record on all available Open Directory nodes. When specified, chpass will edit the user record on the directory node at the given location.
-u authname The user name to use when authenticating to the directory node containing the user.
-s newshell Attempt to change the user's shell to newshell. n.b. if the command is run with sudo it will change the shell for the root user not the current user.
The chfn, and chpass utilities behave identically to chsh. (There is only one program.)
The chpass utility allows editing of the user database information associated with user or, by default, the current user.
The chpass utility cannot change the user's password on Open Directory systems. Use the passwd utility instead.
The information is formatted and supplied to an editor for changes.
Only the information that the user is allowed to change is displayed.
The standard shells that chsh will allow users to change to (or from), without root permission, are those listed in the file /etc/shells.
Use cat /etc/shells to list them, typically:
If installed via brew then bash will be located in /usr/local/bin/bash
To view the current default shell, use: dscl . -read ~/ UserShell
To view the current shell, use: echo $SHELL
On the command line echo $0 will also display the current shell, in a script this will return the name of the file or the program.
These may be different, if you have manually launched a new/different shell, or in Terminal ➞ Preferences ➞ General, there's a setting for Shells open with if that is set to to anything other than 'Default login shell' then it will replace the setting made with chsh.
On macOS a consequence of this change is that the following message is printed every time bash is invoked:
The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050
This can be suppressed by adding:
After changing shell, you should review your shell startup files and transfer any important settings, e.g. a modified PATH to the relevant files.
Set the current user to start all new terminal sessions using the Apple supplied Bash version 3.2:
chsh -s /bin/bash
Set the current user to start all new terminal sessions using a brew installed Bash version 5.0:
chsh -s /opt/homebrew/bin/bash
Set the current user to start all new terminal sessions using zsh (the default).
chsh -s /bin/zsh
“Insisting on perfect safety is for people who don't have the balls to live in the real world” ~ Mary Shafer NASA Flight Research Center
passwd - Modify a user password.
HT208050 - How to change your default shell in macOS (GUI or command line).
macOS startup files - .zprofile and .bash_profile