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.
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.
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
.
3. Use the chsh command to change the currently running shell:
chsh -s [path-to-bash]
4. Enter the administrative password when prompted.
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.
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.
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.
4. Type your password to confirm the administrative privileges for your user and select Unlock.
5. Expand the list of available shells and select the /bin/bash option. Confirm the selection by clicking OK.
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
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
5. Change the default shell with the chsh
command:
chsh -s [path-to-bash]
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.