How to Change Shell in Linux

Bash is the default shell on the vast majority of Linux systems. A shell is what you interact with in the command line terminal, and it interprets your commands. But there are many other shells (interpreters) available, and they all work a bit differently. In this tutorial, you will learn how to change the shell in Linux.

Change Shell in Linux

Example 1. Before changing the shells, check how many shells your Linux system has.

$ cat /etc/shells 

Example 2. Check the current shell by using the echo command.

$ echo $SHELL
/bin/bash

Example 3. You can also check a different user’s default shell by looking inside of the /etc/passwd file. For example, to check the shell for user “linuxnightly”:

$ cat /etc/passwd | grep linuxnightly
linuxnightly:x:1000:1000:k:/home/linuxnightly:/bin/bash

Example 4. You can change the default login shell for a user with the usermod command. This command will change the shell to /bin/bash for user “linuxnightly”:

$ sudo usermod --shell /bin/bash linuxnightly

Reboot or log in again for changes to take effect.

Example 5. The chsh command can also be used to change the login shell for a user. This command will change the shell to /bin/bash for user “linuxnightly”:

$ sudo chsh -s /bin/bash linuxnightly

Reboot or log in again for changes to take effect.

Example 6. If you want to change the shell temporarily, you can simply enter the full path to the shell. For example, to change to the /bin/sh shell:

$ /bin/sh

Leave a Comment

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