SEARCH

How do I change my Terminal from zsh to bash

Switching Your Mac Terminal from Zsh to Bash: A Step-by-Step Guide

If you've recently got a new Mac or have been exploring your system settings, you might have noticed your Terminal window defaulting to something called "zsh" (Z shell) instead of the more traditional "bash" (Bourne Again SHell). While zsh offers some neat features, many users are more familiar and comfortable with bash. This article will walk you through the process of changing your default shell from zsh back to bash, ensuring your Terminal experience is just the way you like it.

Understanding the Change

Apple, by default, switched the default shell for new macOS users from bash to zsh starting with macOS Catalina (10.15). This means if you've updated or purchased a Mac recently, you're likely using zsh. Bash has been the standard for a long time, and many users have scripts, configurations, and muscle memory built around it. Thankfully, switching back is a straightforward process.

Method 1: Using the Terminal Preferences (Recommended for Most Users)

This is the easiest and most common way to change your default shell. It involves a few clicks within the Terminal application itself.

  1. Open Terminal:

    You can find Terminal in your Applications folder, under Utilities. Alternatively, you can use Spotlight Search by pressing Command + Space, typing "Terminal," and hitting Enter.

  2. Access Terminal Preferences:

    Once Terminal is open, click on "Terminal" in the menu bar at the top of your screen (next to the Apple logo). From the dropdown menu, select "Settings..." or "Preferences..." (the wording might vary slightly depending on your macOS version).

  3. Navigate to Profiles:

    In the Settings/Preferences window that pops up, you'll see several tabs. Click on the "Profiles" tab. This section allows you to customize the appearance and behavior of different Terminal windows.

  4. Select Your Default Profile:

    On the left side of the Profiles tab, you'll see a list of available profiles (e.g., "Basic," "Pro," "Homebrew"). Choose the profile that you currently use or want to set as your default. Usually, "Basic" is the default profile.

  5. Change the Startup Command:

    With your chosen profile selected, look for a section labeled "Shells open with" or "Command." This is where you specify what command runs when a new Terminal window opens. By default, it's likely set to run zsh.

  6. Enter the Bash Command:

    You'll see an option to "Run command" or a text field. In this field, you need to enter the path to the bash executable. The standard location for bash on macOS is:

    /bin/bash

    Alternatively, you can choose the option "Login shell" and then select "Call the default login shell." If bash is your system's default login shell, this will work. However, explicitly typing /bin/bash is more direct and ensures it.

  7. Close and Reopen Terminal:

    After making the change, close the Settings/Preferences window. Then, close all open Terminal windows and open a new one. You should now see the familiar bash prompt.

Method 2: Using the `chsh` Command in Terminal

This method involves using a command-line utility called `chsh` (change shell). It's a more direct way to modify your user's default shell.

  1. Open Terminal:

    Launch your Terminal application.

  2. Run the `chsh` Command:

    Type the following command and press Enter:

    chsh -s /bin/bash

  3. Enter Your Password:

    You will be prompted to enter your user account password. Type it in and press Enter. Note that as you type, you won't see any characters appear on the screen – this is a security feature.

  4. Verify the Change:

    The command should indicate that the shell has been changed. To confirm, you can type the following command:

    echo $SHELL

    This should output /bin/bash. If it still shows /bin/zsh, you might need to log out of your macOS user account and log back in for the change to take full effect, or try Method 1.

  5. Open a New Terminal Window:

    Close any open Terminal windows and open a new one. It should now be running bash.

Important Considerations

  • Your User's Default Shell: The `chsh` command changes the default shell for your specific user account. This is generally what you want.
  • System-Wide Default: While you can change the system-wide default shell, it's generally not recommended unless you have a specific reason and understand the implications. Method 1 and Method 2 primarily affect your user's default.
  • Reverting Back: If you ever decide you want to switch back to zsh, you can follow the same steps as above but use /bin/zsh instead of /bin/bash.
  • Customizations: If you've made significant customizations to zsh (like Oh My Zsh), those configurations won't automatically transfer to bash. You'll need to set up bash customizations separately (e.g., by editing your .bash_profile or .bashrc file).

Frequently Asked Questions (FAQ)

How do I know which shell I'm currently using?

When you open your Terminal, look at the prompt. Typically, bash prompts end with a dollar sign ($), while zsh prompts often end with a percentage sign (%) or have more elaborate formatting if you're using a framework like Oh My Zsh. You can also type echo $SHELL in the Terminal, and it will display the path to your current default shell.

Why did my Mac switch to zsh by default?

Apple switched to zsh as the default shell for new macOS installations starting with Catalina to promote a more modern and feature-rich shell. Zsh offers advanced features like improved tab completion, spelling correction, and more powerful scripting capabilities compared to bash.

Will changing back to bash break anything?

For most users, switching back to bash will not break anything. Your existing system applications and commands will continue to work. However, if you have specific scripts or configurations that were written exclusively for zsh's advanced features, those might need to be adapted. Also, any customizations you've made to zsh (like themes or plugins) will not be active in bash.

What's the difference between bash and zsh?

Bash and zsh are both Unix shells, which are command-line interpreters. Zsh is generally considered more powerful and customizable than bash, offering features like advanced tab completion, better spelling correction, and more robust globbing. Bash is older, widely compatible, and many users are very familiar with its syntax and behavior. For most everyday tasks, both are perfectly capable.