A shell is a program that acts as the outermost layer of an operating system through which you interact with its various programs and services. Most Linux distros use bash as their default shell. However, you're free to choose another shell for your system if you want.

Besides bash, Linux also supports other shell programs, such as ksh, zsh, csh, and fish. Each of these shells has some unique characteristic that sets them apart from bash and the other shells.

Let's dive in to learn more about shell and how to change your default Linux shell.

What Is a Shell, and What’s Its Significance?

A shell is a computer program that allows you to control various elements of an operating system using commands. When you use a terminal in Linux, you basically interact with the shell sitting between you and the operating system and instruct it to execute commands.

Most Linux shells come with a command-line interface (CLI) and require familiarity with commands (and their syntaxes). When you input a command into the shell, it looks up for the program (in your command) in the system path to determine it. If it finds a match, it executes the command successfully, and you get the output.

In a nutshell, a shell offers a powerful and efficient way of communicating with the operating system.

Related: 5 Reasons to Choose the Linux Terminal Over GUI

Why Would You Want to Change Your Default Shell?

Generally speaking, most shells you’ll come across on Linux or any other Unix-based systems offer pretty much the same functionality for the most part: they let you interact with/control various system elements conveniently.

Bash, which comes preinstalled on most Linux distros, is a perfect example of this. However, when stacked against some of the other shells, like, zsh, for instance, it trails in terms of functionalities.

Zsh, on the other hand, brings along a bunch of additional features, such as auto-completion, auto-correction, automatic cd, recursive path expansion, and plugin support, which gives it an edge over bash and a few other shells.

Of course, these are just a handful of advantages that you get with zsh. Other shells also bring forth their own set of features and enhancements, which makes the entire experience of working with them easier and more convenient.

How to Change Your Default Linux Shell

There are several ways to change the default shell in Linux. We'll demonstrate the process with the chsh utility in this guide since it's a more reliable and convenient method of the lot.

Chsh is a command-line utility on Unix-based operating systems that enables you to change the default shell. It comes pre-installed on pretty much all Linux distros.

To use it, all you have to do is supply the pathname of the shell that you want to use in the terminal, and it takes care of the rest of the process itself. However, you’ll need to go through a few steps before you can change your default shell.

Here's a breakdown of these steps.

Step 1: Identifying the Installed Shells

Before you install a new shell, it's important to know what shells you already have on your Linux system. To do this, open the terminal and type:

        cat /etc/shells
    

Unless you've installed a new shell, your output should look similar to the one in the attached image below.

checking installed shells on Linux

Step 2: Installing a New Shell

Once you've identified the installed shells on your system, the next step is to install a new shell. In this regard, there are a variety of options available on Linux, each with its share of advantages and disadvantages. So depending on your preferences and what you want to achieve with the shell, you can pick one that meets your requirements.

This guide will demonstrate the installation and setup of the zsh shell. Feel free to replace "zsh" with your shell name in the commands that follow.

To install zsh on Debian-based distros:

        sudo apt install zsh
    

You can install zsh on Arch Linux using pacman:

        sudo pacman -Syu zsh
    

Installing zsh on Fedora, CentOS, and other RHEL distros is easy as well:

        sudo dnf install zsh
    

Once the installation is complete, run the below command to check the installed shells on your system again:

        cat /etc/shells
    
checking for newly installed shell on Linux

Next, verify if the installed shell works. To do this, enter the name of your shell in the terminal. If it’s zsh, run:

        zsh
    

To return to the default shell, type exit and hit Enter.

Step 3: Setting a Shell as the Default Shell for Your System

If your newly installed shell appears on the list of installed shells and works fine, you're now ready to set it as the default shell for your system. Do note that, with chsh, you can change both the default interactive shell and the default login shell.

A login shell is a shell where you obtain a terminal after you log in to your system, whereas an interactive shell is available all the time after you've logged in.

To set zsh (or any other shell) as the default login shell, open the terminal and run:

        chsh
    

When prompted for a password, enter your account password and hit Enter.

Next, type the absolute path for your installed shell. This will change the default login shell for your system. To change the default interactive shell to zsh:

        chsh -s /usr/bin/zsh
    

The system will ask you to enter your password to apply the changes. Type in your password and hit Enter.

Once you've set zsh (or another shell) as the default or/and interactive shell, log out and log back in for the changes to reflect on your system.

Now, when you log in again and open the terminal, the system will greet you with the shell configurator. Before you can start using your new shell, you must pick the options here that correspond to your shell requirements.

With everything set, verify if your newly installed shell is set as the system's default shell. To do this, run the following command:

        echo $SHELL
    

If you've set it to zsh, you'll see its path in the terminal. In the case of another shell, it should reflect the path accordingly.

Do note that, if you want to change the default shell for other users on your system, you’ll have to do it individually for each user. For instance, if you’d like to change the default shell for user sam, you’ll need to run the below command:

        sudo chsh -s /usr/bin/zsh sam
    

Changing Default Shell for a Personalized Experience

A feature-rich shell carries a number of additional benefits beyond those inherent to the default shell. And since most of your Linux interactions and operations happen over the command line, changing your default shell to one that offers more features is among the first steps to personalizing your working environment.

In fact, you should consider not just changing the default shell but customizing it and setting it up the way you want it to work to elevate the entire experience. A good place to begin customizing your shell is to start using command-line aliases that make inputting commands in the terminal quick and convenient.