This tutorial covers the following topics:

  • Determining the terminal type used in macOS.
  • Changing the terminal type from the default to a new shell.
  • Listing all available terminals.

How to Change the Default Shell in macOS

To change the default shell in macOS, please follow these steps in the terminal:

Open Terminal on your macOS device.

Since the default shell is zsh, you can change it to a new shell using the chsh command.

chsh -s /bin/bash

It will prompt you to enter your password to confirm the change.

This command replaces the current shell (/bin/zsh) with the new shell (/bin/bash).

Close the terminal and reopen it to see the changes reflected with the new shell.

Check Which Shell Is Running on macOS

There are multiple ways to determine the default running shell.

  • Using the $SHELL variable:

The current shell path is saved as the SHELL variable.

echo $SHELL # /bin/zsh

This command outputs the path of the active shell binaries, which in this case is /bin/zsh.

  • Using the ps command
ps -p $$

This command prints the current process ID information of the current shell.

  • Using the environment variable $0
eco $0

This command prints the shell name, i.e., -zsh.

The above approaches give the active shell on macOS.

List all available shells in MAC

Supported shells are maintained in the /etc/shells file. You can view the file using the commands below:

you can view the file or using below command

sudo \vi /etc/shells

or

sudo nano /etc/shells

Each shell binary is available in the /bin/ directory.

Alternatively, you can use the following command in the terminal.

ls -l /bin/*sh

In either case, your output will contain the list of shells available in your system.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/tcsh
/bin/zsh
/bin/sh