In Linux, the shell is a key part of the command-line environment, acting as the interface that processes and runs commands. Popular shells include Bash, Zsh, and Fish, each offering different features for scripting, customization, and usability. Users can change their default shell to suit their workflow.

Changing the default shell allows users to enhance their experience, whether for improved command-line shortcuts, advanced scripting features, or personal preference. The system stores available shells in a file, making it easy to select one from the list and set it as the default.

The process to change the shell is simple. Users can change the shell by using commands or by updating configuration files. It is important to confirm the shell is installed before making changes. Once done, the new shell takes effect after logging out and back in or opening a new terminal.

Steps to set the default shell in Linux:

  1. Open a terminal window.

    Make sure you have root privileges if required.

  2. Check the current default shell.
    $ echo $SHELL
    /bin/bash
  3. List available shells on the system.
    $ cat /etc/shells
    /bin/bash
    /bin/sh
    /usr/bin/zsh
  4. Install the desired shell if it is not available.

    Use your distribution's package manager. For Ubuntu, use apt.

    $ sudo apt install zsh
  5. Change the user’s shell using the command-line tool.
    $ chsh -s /usr/bin/zsh
  6. Close the terminal window.

    This step ensures changes take effect on reopening.

  7. Open a new terminal window to confirm the shell change.

    If the change is successful, the terminal will start with the new shell.

  8. Verify the new default shell.
    $ echo $SHELL
    /usr/bin/zsh
Discuss the article:

Comment anonymously. Login not required.