How to Change Shell in Linux [3 Effective Methods]

Written by

Reviewed by

Last updated: August 1, 2023

Expert verified

SVG Image


To change shell in Linux, you can try the following methods:

  1. chsh Command: Use chsh -s /path/to/desired/shell and authenticate to switch your default shell.
  2. /etc/passwd File: Manually edit /etc/passwd file, changing the shell path and logout/login for the changes.
  3. Installing a New Shell: Install the shell through the package manager, then use chsh to set it as default.

To see all available shells on your Linux system, check the contents of the /etc/shells file. This will display a list of installed shells, such as Bash, Zsh, sh, and Fish. For changing shells, use the chsh command with the desired shell’s path. Customize your new shell, install plugins and themes for added functionality, and don’t hesitate to revert to the default shell if needed.

Read the article below to learn different methods to change shell in Linux and the tips and tricks to change shell in Linux.

In Linux, a shell is a command-line interpreter that lets you communicate with the operating system through text-based commands. It acts as a bridge between the user and the kernel, processing commands and providing output accordingly. Changing shells in Linux offers enhanced productivity, personalization, access to advanced features, an easier learning curve, and the ability to adapt to different tasks. In this article, I will explore different methods to change shell in Linux and the expert tips and tricks to follow when changing shells.

How to Change Shell in Linux

To change shell in Linux, there are three methods. The first one is using the chsh command, which allows a quick switch to a different shell with authentication. The second method involves manually editing the /etc/passwd file to change the default shell, providing hands-on control. The third approach is installing a new shell via the package manager, enabling users to explore different shells without altering the system’s default setting.

1. chsh Command

The chsh command is a quick and straightforward method to change your default shell, ideal for users who want an immediate switch. By using the chsh command, users can swiftly switch to a different shell, experiencing its unique features and improved functionality without any manual file editing. Here’s how to do it:

  1. Open a Terminal window. You can do this by pressing Ctrl + Alt + T.
opening terminal
  1. Type the following command and press Enter:
<strong>echo $SHELL</strong>
  1. The output will display the path of your current default shell.
checking current shell
  1. Type the following command to change shell using chsh command:
<strong>chsh -s /path/to/your/desired/shell</strong>

Replace /path/to/your/desired/shell with the path of the shell you want to use. For instance, to switch to Zsh, you would use /usr/bin/zsh.

  1. You will be prompted to enter your user password for authentication.
changing shell using chsh command
  1. Once authenticated, the shell change will take effect immediately.
shell has been changed

2. /etc/passwd File

Manually editing the /etc/passwd file suits users who prefer a hands-on approach and full control over their shell change. With direct access to the /etc/passwd file, users can make detailed adjustments, ensuring a seamless transition to the desired shell while maintaining a personalized command-line environment. Please proceed with caution and make backups before proceeding:

  1. Access your command window and use a text editor such as nano or vim to open the /etc/passwd file:
<strong>sudo nano /etc/passwd</strong>
  1. The command will open the /etc/passwd file in nano editor.
opening passwd file in nano editor
  1. Locate the line that corresponds to your username. It should look like this:
<strong>your_username:x:1000:1000:Your Name,,,:/home/your_username:/bin/your_current_shell</strong>
  1. Change /bin/your_current_shell to the path of the shell you want to use (e.g., /bin/zsh for Zsh).
  2. Save the file and exit the text editor.
changing shell by editing passwd file
  1. Logout and log back in for the changes to take effect.
login again to view shell change


3. Installing a New Shell

Installing a new shell through the package manager is an excellent option for users curious about exploring different shells without changing the system’s default shell. Follow these steps:

  1. Launch your command prompt.
  2. Use the appropriate package manager to install the desired shell. For example, to install Zsh, run the following command:
<strong>sudo apt update</strong>
  1. The command will update the system packages.
updating system package list
  1. Now run the following command command to install Zsh:
<strong>sudo apt install zsh</strong>
  1. After installation, you can set the installed shell as your default using Method 1.
installing new shell

How to see all the shells available on your Linux system?

To see all the shells available on your Linux system, you can check the contents of the ‘/etc/shells’ file. This file typically lists the paths of all the shells installed on your system. Keep in mind that the ‘/etc/shells’ file may vary slightly between different Linux distributions, but it generally serves the same purpose of listing available shells. Some distributions may also store this information in a different location, but the ‘/etc/shells’ file is the most common place to find it. Here’s how you can view the available shells:

  1. Open a Terminal window on your Linux system.
  2. Type the following command and press Enter:
<strong>cat /etc/shells</strong>
  1. The output will display a list of paths corresponding to the available shells. Each line represents a different shell installed on your system.
listing all available shells

Changing Shells in Linux: Tips and Tricks

Changing shells in Linux allows users to customize their command-line experience and boost productivity. With these expert tips and tricks, you can confidently transition to a different shell in Linux, unlocking a world of possibilities for a more tailored and efficient command-line experience. Here are five tips and tricks to follow:

  • 🔍 Explore Available Shells with ‘cat /etc/shells’: Before making a switch, it’s essential to explore the shells available on your system. Use the command cat /etc/shells in your Terminal to view a comprehensive list of installed shells. This will enable you to make an informed choice based on your needs, preferences, and the features offered by each shell. Familiarizing yourself with the available options ensures that you select the shell best suited for your workflow and objectives.
  • 🔄 Change Default Shell with ‘chsh’ Command: Once you’ve decided on the new shell, changing the default one is straightforward using the chsh command. Open your Terminal and execute the command chsh -s /path/to/shell, replacing /path/to/shell with the actual path of the desired shell (e.g., ‘/bin/zsh’ for Zsh). You’ll be prompted to enter your user password for authentication. Once authenticated, the change will take effect immediately. You can verify the updated default shell by running the command echo $SHELL. Embrace your new, more powerful and efficient shell.
  • ⚙️ Customize Your New Shell: To maximize the benefits of your chosen shell, consider customizing it to align with your specific workflow and preferences. Tailor the shell prompt to display relevant information, create aliases for frequently used commands to save time, and set environment variables to customize your shell’s behavior. Each shell offers unique customization options, empowering you to create a personalized and productive command-line environment. Investing some time in customization pays off in the long run, making your daily tasks more enjoyable and efficient.
  • 🛠️ Install Plugins and Themes: Many shells offer extensive plugin support, providing additional functionality and streamlining your workflow. For example, Oh My Zsh and Fisherman are popular plugin managers for Zsh and Fish shells, respectively. These managers provide a wide array of add-ons, themes, and utilities that enhance your shell experience. You can find plugins to automate common tasks, improve command completion, and add eye-catching themes. Exploring and installing the right plugins can significantly boost your productivity and make your interaction with the shell more enjoyable.
  • 📝 Reverting to the Default Shell: Sometimes, despite careful consideration, a new shell may not meet your expectations or may cause unforeseen issues. If this happens, don’t worry; you can easily revert to your default shell. Use the chsh command again and specify the path of your original shell to restore it as the default. Alternatively, you can manually edit the /etc/passwd file, changing the shell path back to the original one. After making the change, log out and log back in to apply the modification. Always remember that experimenting with shells is a learning process, and it’s perfectly normal to try out different options before finding your perfect fit.

In Conclusion

I’ve provided you with various methods to change shell in Linux, including using the chsh command and modifying the /etc/passwd file. Additionally, I shared five valuable tips and tricks to facilitate a smooth transition to a new shell, such as exploring available shells, customizing your new shell, installing plugins and themes, and how to revert to the default shell if needed.

To further enhance your Linux journey, consider exploring advanced shell scripting to automate tasks, mastering essential shell commands for efficient system management, and exploring various shell customization options. Keep exploring the Linux community and its latest developments to stay on top of the game.

Frequently Asked Questions

Will changing my shell affect existing scripts and applications?

Generally, changing the default shell won’t impact existing scripts and applications. Most commonly used scripts are designed to be shell-agnostic, relying on universal commands and syntax. However, it’s essential to exercise caution with complex or highly customized scripts. Some scripts may use specific shell features or commands that might differ between shells. In such cases, you may need to make minor adjustments to ensure compatibility with the new shell. Before making the switch, it’s advisable to test critical scripts in the new shell environment to identify any potential issues and address them proactively.

Can I customize the appearance and behavior of the shell differently for each user?

Absolutely! Linux offers the flexibility to customize the appearance and behavior of the shell for each user independently. When a user logs in, their shell configuration is read from their specific configuration files, allowing them to personalize their shell environment. Users can modify the shell prompt to display relevant information, create aliases for frequently used commands, and set environment variables according to their preferences. This feature enables multiple users on the same system to have a unique and tailored command-line experience that caters to their individual workflows and needs.

How do I revert to the default shell if I encounter issues with the new one?

If you encounter issues with the new shell and wish to revert to the default one, you have a couple of options. One way is to use the chsh command again and specify the path of your original shell as the default. Open a Terminal and enter: chsh -s /path/to/default/shell. Replace /path/to/default/shell with the path of your original shell (e.g., /bin/bash for Bash). Alternatively, you can manually edit the /etc/passwd file. Open the file in a text editor with administrative privileges, find the line corresponding to your username, and change the shell path back to the original one. After making the change, save the file and log out and back in for the modifications to take effect.

Can I switch between shells without logging out and logging back in?

Yes, you can switch between shells without the need to log out and log back in. Once you change the default shell using the chsh command, the updated shell will automatically take effect for any new Terminal sessions opened thereafter. However, to apply the change to the current Terminal session without logging out, you can use the exec command. Simply enter the following command in your Terminal: exec $SHELL. This command will reload the current shell with the new default shell settings, immediately reflecting the change in your current session. This way, you can seamlessly transition between shells and test out different configurations without interrupting your workflow.



Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.



Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

Start, Stop, and Restart Services in Linux using 3 Effective Ways

Next Post

How to Exit a Docker Container Like a Pro [5 Best Methods]

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next