Change default shell to bash on Macos Catalina

last updated in Categories , ,

I noticed that my default shell set to zsh on Macos Catalina. How do I change my default shell to bash on Macos Catalina using the command line or GUI options?

A Unix shell is nothing but a program that accepts Unix commands from the keyboard and executes them. For a long time, the bash was a default shell in macOS. However, Apple replaced Bourne Again SHell with Z shell for licensing reasons. This page explains how to set up bash as your default login shell and interactive shell.

Set default shell to bash on Macos Catalina

The procedure is as follows:

  1. Open the terminal application.
  2. List available shells by typing cat /etc/shells.
  3. To update your account to use bash run chsh -s /bin/bash.
  4. Close terminal app.
  5. Open the terminal app again and verify that bash is your default shell.

Let us see all commands in details.

List your shell options on Unix

Simply run the following cat command:
cat /etc/shells
macOS Catalina set zsh as default shell

How to change your zsh to bash on macOS

Simply type the following command:
chsh -s /bin/bash
Set and change default shell to bash
Close the terminal Window and reopen it again. Next you need to type the following command to make sure your user account is configured to use zsh on Unix using the printf command/echo command:
echo $SHELL
OR
printf "%s\n" $SHELL
Sample outputs:

/bin/bash

Find out your bash version

Type the following command:
bash --version
Sample outputs:

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

I am using bash version 3.2.57 on macOS.

How do I update or upgrade bash version?

Homebrew user can type the following brew command to install the lastst version of bash on Catalina:
brew install bash
The newer version of bash is located at /usr/local/bin/bash:
ls -l /usr/local/bin/bash
cat /etc/shells

If not in /etc/shells, append it:
sudo -i
echo /usr/local/bin/bash >> /etc/shells

Set default shell to /usr/local/bin/bash, run the following chsh command
chsh -s /usr/local/bin/bash
How to upgrade bash version on Macos Catalina
Verify new version:
bash --version
/usr/local/bin/bash --version

Sample outputs:

GNU bash, version 5.0.11(1)-release (x86_64-apple-darwin19.0.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Conclusion

You learned how to set and use bash as the default shell on your Mac Catalina as Apple changed the default from bash to zsh.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive