CentOS Debian Mint openSUSE Red Hat Ubuntu

How to Change the Default User Shell in Linux OS

How to Change the Default User Shell in Linux OS

You must have been familiar with the bash shell which we commonly use in the Linux system. In most of the Linux operating systems the default shell is bash but do you know we can change the default bash shell to any other shell like sh, fish, zsh, csh etc. In this article, we will learn how to change the default user shell in Linux OS.

Find the current shell name

To change the default user shell, first of all find the current shell you are using. In the Linux system, the default user shell is bash. There is one file named passwd under the directory /etc that stores essential user account information which is needed during the user log in. We can identify the current user shell using that file.

Run the following command to check current user information stored in the file /etc/passwd.

$ grep <current_user> /etc/passwd


$ grep aayush /etc/passwd

In the above example, aayush is the username and bash is the current shell.

Also, you can use echo command to check the current user shell.

$ echo $SHELL

List available shells in Linux

To change the user default shell, we need to find out the available shell lists in the Linux system.

Installed shells can be listed by using the following command.

$ cat /etc/shells

It can be seen that different types of shell such as bash, rbash and dash are available in the system.

Before changing the shell, remember the following things.

  • Root user can be used to change login shell of other users
  • If any user account has restricted login shell, then only root user can change the user’s shell
  • Users will be able to change the shell listed in /etc/shells only.

Changing default sh shell to bash shell

In the Linux operating system, there are many ways to change the default login shell. In this article, we will explain some commonly used methods.

Using chsh utility

If you want to change the default user shell then the chsh utility can be very useful. Run the command chsh with the option -s to change the user shell. It also modifies the /etc/passwd file.

$ chsh -s /bin/sh aayush

Where , aayush is the username and sh is the shell we are going to change.

In this example, the default user shell has been changed from bash to sh.

Using usermod command

The usermod utility is another way to modify the user account. You just need to specify the option -s or -shell to change the default shell for a user. Remember that you need to have a root privileged account to make the changes. Using usermod does not change the user’s current shell but sets a default shell to be used in the next login.

$ sudo usermod -s /bin/bash aayush

In the above example, the default shell of the user has been changed from bash to sh.

By editing in passwd file

In the linux system, essential user’s information is stored in the file /etc/passwd which is needed to login. Default user shell can also be changed by manually editing this file. For this edit the file /etc/passwd using any text editor and change the shell after the username and home directory of a user and save a file.

$ sudo vi /etc/passwd

Change the current user shell

Changing the current user shell is simple and easy. Just type the shell you want to use in the terminal. But this does not change the default shell for the next login.

$ rbash


In this article, we learned different ways to change default user shell in Linux OS


Similar Posts