What is a Linux Shell?
When you open the terminal in Linux, you are interacting with a program called a shell. The shell is the command-line interpreter that takes the text commands you type, translates them into instructions the operating system can understand, and then returns the output to your screen.
By default, almost every modern Linux distribution (including Ubuntu, Debian, and Fedora) uses a shell called Bash (Bourne Again SHell). Bash is incredibly stable, widely supported, and serves as the industry standard. However, it is not the only shell available.
Many power users prefer alternative shells like Zsh (Z shell) or Fish (Friendly Interactive Shell) because they offer advanced features that Bash lacks, such as superior auto-completion, powerful plugin ecosystems (like Oh My Zsh), inline syntax highlighting, and highly customisable prompts.
If you have installed a new shell and want your terminal to automatically use it every time you open a new window, you need to change your user account’s default shell using the chsh command.
Step 1: Verify Which Shells Are Installed
Before you can change your default shell, you must confirm that the new shell is actually installed on your system and find its exact file path. The operating system keeps a list of all approved, installed shells in a specific configuration file.
- Open your terminal application.
- Type the following command to view the contents of the authorized shells file:
cat /etc/shells - Press Enter.
You will see an output similar to this:
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dash
/usr/bin/zsh
/bin/zsh
Look through the list to ensure the shell you want (for example, /bin/zsh) is present. If it is not listed, you need to install it first using your package manager (e.g., sudo apt install zsh on Ubuntu) before proceeding.
Step 2: Check Your Current Default Shell
It is good practice to confirm what shell you are currently using before you make any changes, so you know exactly what to revert to if something goes wrong.
Type the following command into your terminal and press Enter:
echo $SHELL
The terminal will output the path to your current active shell, which will most likely be /bin/bash.
Step 3: Change the Default Shell Using chsh
The chsh (Change Shell) command is the standard, safest way to update your user profile’s shell preference.
- In your terminal, type
chsh -sfollowed by a space and the exact path to your new shell that you found in Step 1. For example, to change to Zsh, you would type:chsh -s /bin/zsh - Press Enter.
- The system will prompt you to enter your user account Password. This is a security measure to prevent malicious scripts from changing your terminal environment without your consent. Type your password (the characters will remain invisible as you type) and press Enter.
If the command is successful, the terminal will simply return to a new prompt line without showing an error message.
Step 4: Log Out and Log Back In
Changing your default shell does not immediately affect the terminal window you currently have open, nor does it immediately affect background processes.
For the system to apply the new default shell to your user profile, you must log out of your Linux desktop environment completely and log back in. Alternatively, you can simply restart your computer.
Once you have logged back in, open a fresh terminal window. Type echo $SHELL again to confirm that the output now matches your newly selected shell.