How to Switch from Zsh to Bash on Mac

August 2, 2023

Introduction

Zsh replaced Bash as macOS's default terminal shell in macOS Catalina. While Zsh is in many ways superior to Bash, thanks to its floating-point support, hash data structures, customization options, etc., there are still use cases where Bash may prove helpful in the macOS terminal.

This article teaches you how to switch to Bash from Zsh on macOS using CLI and System Settings.

How to switch from zsh to bash on macOS.

Prerequisites

  • macOS Catalina or later.
  • Administrative access to the system.

How to Check What Shell Mac Is Using?

If you are unsure about which shell you are using, open the terminal application and enter the following ps command:

ps -p $$

The output shows the active shell process. The CMD column shows the name of the currently running shell.

The ps command displaying the process related to the currently running shell.

How to Change Zsh to Bash on Mac?

Change the default terminal shell in macOS using the CLI or the System Preferences GUI. The following sections explain both methods.

Via Terminal

Using the terminal to switch from Zsh to Bash on macOS is a short and straightforward procedure.

Follow the steps below to replace Zsh with Bash:

1. View the list of available shells on the system by typing:

cat /etc/shells

2. Find and note the path to the Bash executable in the list. Most often, the default Bash path is /bin/bash.

Viewing the list of available shells on macOS.

3. Use the chsh command to change the currently running shell:

chsh -s [path-to-bash]

4. Enter the administrative password when prompted.

Changing the shell to Bash in macOS.

5. Exit the terminal by entering:

exit

Next time you open the terminal, the Bash prompt appears alongside a warning stating that Zsh is the default shell.

Bash shell showing up in the macOS terminal.

Via System Settings

The System Settings app allows users to access all the critical system configuration options in one place. Follow the steps below to change the terminal shell using System Settings.

1. Click the Apple logo, then select System Settings in the menu.

Finding System Settings on macOS.

2. Select the Users & Groups section in the menu on the left side of the window.

3. Hold the Control key and select your user to show the Advanced Options item. Select the item to access more user-related options.

Finding advanced user options in System Settings on macOS.

4. Type your password to confirm the administrative privileges for your user and select Unlock.

Providing administrative access password for the advanced user options.

5. Expand the list of available shells and select the /bin/bash option. Confirm the selection by clicking OK.

Selecting Bash from the list of the available shells in System Settings.

Open the terminal and confirm that it is now running Bash.

How to Update Bash on Mac?

By default, macOS provides an outdated Bash version (Bash 3.2.57 from 2007). If you wish to install the newest version of Bash, use the Homebrew package manager. Follow the steps below to install Bash with Homebrew.

1. Update and upgrade your Homebrew formulae:

brew upgrade

2. Install the Bash Homebrew formula:

brew install bash
Installing Bash with Homebrew.

3. Reload the shell with the exec command:

exec bash

4. Add the Bash Homebrew installation path to the list of available shells:

echo $(brew --prefix)/bin/bash | sudo tee -a /private/etc/shells
Adding the Homebrew version of Bash to the list of available shells in macOS.

5. Change the default shell with the chsh command:

chsh -s [path-to-bash]
Changing the shell to the Homebrew version of Bash in macOS.

Conclusion

The article showed you how to switch from Zsh to Bash shell on macOS. It also provided instructions on how to ensure your system runs the latest Bash version.

If you plan to use Bash to run scripts, check out our Bash script tutorial.

Was this article helpful?
YesNo
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
Mac Terminal Commands
May 18, 2023

While many Mac terminal commands are similar to Linux commands, macOS also features system-specific syntax designed to help Mac users manage their hardware and software.
Read more
How to Set Environment Variables in MacOS
January 18, 2021

Environment variables are used to store system-wide values that can be used by any user and process under the operating system.
Read more
How to Install Java on Mac
July 21, 2022

Java-based apps and applets are created using a software development environment (SDE) known as the Java Development Kit (JDK). The JDK comes with...
Read more
How to Install Pip on Mac
December 14, 2023

Pip is a package management system used for installing and managing Python software packages and libraries. The software and libraries are stored in...
Read more