How to Change zsh to bash on Mac

If you have been a Mac Terminal user for many years, you have probably noticed that recent releases of macOS have changed the Mac Terminal application to use zsh as the default command shell. Also known as Z Shell, it is one of the latest command shells available.

This can be disappointing for some, but there are some easy solutions if you wish to have your old bash shell back. The quickest way is to type bash on the command line in the Mac Terminal, but if you want, you can also set bash to be your default shell instead of zsh.

My name is Eric, and as a software engineer, I use command line interfaces like Mac Terminal daily. I know that it can be a comfort to use the tools you are familiar with, and changing to a new shell can often affect your productivity, so I can show you how to change it back.

Read below if you want to see more details about changing back to bash and how to set it as your default shell. I will also discuss why Mac Terminal has started using zsh, why you would want to change it, and what effects it could have.

Quick Change to bash

The easiest and quickest way to change from zsh to bash is to open a Mac Terminal session and type in the bash command below.

bash

When you do this, you will see a message, as shown above, stating that the default interactive shell is zsh, and it tells you how to update your account to use zsh. There’s no need to do this because Mac Terminal is already set to use zsh, and you want to use bash anyway.

It knows you are using bash and wants you to change to zsh, so you can ignore this message. There is no need to take any action from here, as you are in bash shell, and you will remain there until you use the exit command to get out of it.

Just type the exit command as shown below, and you will exit from bash back to zsh.

exit 

Using the bash and exit commands to switch back and forth from zsh to bash is my preferred method to do this. This is because I can quickly and easily switch with one command, and it leaves my default set to zsh. This is the latest and greatest, so I still have it if needed.

Setting bash as your Default Shell

If you want to use bash all the time and don’t want to remember to type in the bash command every time you start to do something, you can set Mac Terminal’s default to bash. Just follow the steps below to do this.

Step 1: Open Terminal

Use your preferred method to open the Terminal application.

Step 2: Go to Terminal settings.

Click on the Terminal settings from the Menu at the top of the screen.

Step 3: Change the default shell.

In the section labeled Shells open with, click on the radio button that says Command (complete path):, type in /bin/bash into the text field to tell it that you wish to use bash.

Step 4: Exit and restart the Terminal application.

Get out of the settings page and then exit the Terminal application. When Terminal restarts, you will be in bash shell.

After setting bash as your default, you will not have to worry about typing the command every time you start up Mac Terminal; you will automatically be in bash when it starts.

Checking your Shell

If you are switching back and forth between shells and are just not sure what shell you are in, you may wonder how you can tell which one you are using at any specific time. Many times, you can tell by the command prompt. You will see a % prompt for zsh and a $ prompt for bash.

While the prompt is usually a good sign of what shell you are in, you can’t always trust it because the command prompt can be configured to use any characters. You may not need to worry if you have never changed the configuration of your command prompt. Still, there is another way to ensure which one you are using.

To check which shell you are in, simply type a command that does not exist, and you will see an error message showing the current shell and stating that the command does not exist. For example, I could type the following command, which does not exist.

testmyshell 

As you can see in both cases above, it shows an error message and indicates the shell is looking for the non-existing command.

FAQs

Below are some frequently asked questions that come up when discussing how to change from zsh to bash on Mac.

Why Did Apple change to zsh?

Apple changed to zsh because it is one of the latest and greatest shells available. It has more features and capabilities than bash, and it is compatible with many other UNIX/LINUX operating systems. It’s just a matter of Apple keeping updated with the latest technologies.

Why would anyone want to change back to bash?

Many of us old-school command line users have been using bash for some time, and it’s really just that we are comfortable using it. There is a possibility that you might have some shell scripts written in bash that you wish to use and may have compatibility issues, but for the most part, your old bash scripts should work in zsh. If not, they may only need slight modifications.

Will changing to bash cause any issues?

Changing to bash in your terminal session should not cause any issues for the most part. When you run bash in your Mac Terminal session, you are just running it in your local session, and it will not affect how your Mac runs. The only thing that may be affected is if you or your system has some shell scripts that run and are written in zsh. Most commands in the script will work, but compatibility issues are possible.

Can I change to other shells?

Yes, you can, as long as installed on your system. I know that my system also has ksh or k shell on it, and I can easily switch to it if I want by typing ksh. There are most likely others on your system, and I am sure there are some that you can install on your system if you wish to do so.

Conclusion

Switching from zsh to bash on your Mac is easy by simply typing the bash command on the command line from your Mac Terminal. You can then exit bash and return to zsh by typing the exit command.

If you want to switch to bash as your default shell, you can also do that by following the steps I have outlined above. 

I hope the information I have provided can help you to be able to change from zsh to bash when you want to do so. As usual, let me know if you have any questions or comments. I would love to hear from you.

Leave a Reply

Your email address will not be published. Required fields are marked *