change default shell in linux

How to Change Default Shell In Linux

Every Linux user has a default shell assigned to it at the time of user creation. But sometimes you may want to change the default shell for logged in user or another user in Linux. In this article, we will look at how to change default shell in Linux.

How to Change Default Shell In Linux

Here are the steps to change default shell in Linux.

1. List all shells

Linux systems generally come loaded with multiple shells. Open terminal and run the following command to list all the available shells in your system.

$ cat /etc/shells

You should see an output similar to the following.


It lists the full path for each shell such as bash, cshell, etc. Please note the full path to the shell of your choice, as you will need to use it in the next step.

2. Change default shell

We will use chsh command, created specifically to change user’s default shell. Let us say you want to change default shell to csh. In this case, enter the following command mentioning the full path to shell after chsh -s

$ sudo chsh -s /bin/csh
$ sudo chsh --shell /bin/csh

Please note, you need to mention the full path to the shell of your choice, that you had noted in previous step.

The above command will change shell of only current user that you have logged in as. If you want to change the shell of another user (e.g. test_user), you need to mention that username after the new shell’s path, as shown below in bold

$ sudo chsh -s /bin/csh test_user
$ sudo chsh --shell /bin/csh test_user

Please note, you can change shell for another user only if you are logged in as root or user with sudo privileges.

You can also find out the full path to a shell using type command. Here is an example to find out the full path of cshell.

$ sudo type -a csh

3. Verify New Shell

The /etc/passwd contains login information about every user on your system that has access. It also contains the information about default shell for each user. You can run grep command searching for your username in it, to find out the latest default shell. It will be mentioned at the end of the output, highlighted in bold below.

$ grep "^${USER}" /etc/passwd

If you need more information about chsh command, just use man command

$ man chsh

In this article, we have learnt how to change default shell of Linux user using chsh command.

Also read:

How to Install Moodle with NGINX in Ubuntu
How to Download File Using Python
How to Run CGI Script in Apache
How to Create Permanent Alias in Linux
How to Give User Access in Linux

Leave a Reply

Your email address will not be published.