How to Change Default Shell In Linux

Page 1

Every Linux system supports multiple shells. By default, every Linux distribution has a default shell assigned for each user. This is the shell we get when we open terminal on our Linux system. You can always change this shell after you have started terminal session. But sometimes you may need to change this default shell itself instead of changing it every time, since it does not meet our requirements. In this article, we will learn 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

If you are sure about the new shell that you want to switch your default shell to, then you can skip this step. Else run the following command to list all available shells on your system. Every Linux system ships with multiple shells.

$ cat /etc/shells

You will see the following kind of output.

/bin/sh

/bin/bash

/sbin/nologin

/bin/tcsh

/bin/csh

/bin/dash

It lists the full path for each shell such as cshell, bash, etc. Note the full path of the shell you want to switch to.

2. Change Default Shell

Linux provides chsh command to change default shell for user. Let us say you want to set default shell to csh. In this case, run the following command to change shell.

$ sudo chsh -s /bin/csh

OR

$ sudo chsh --shell /bin/csh

Please note, you need to mention full path to your new shell as shown above. This command will change the shell only for current logged in user. If you want to change shell for another user, say, test_user, then add that username after the above command.

$ sudo chsh -s /bin/csh test_user

OR

$ sudo chsh --shell /bin/csh test_user

Please note, to modify default shell of another user, you need to be logged in a root or sudo user.

If you want to find out the full path of your present shell, that is, verify the change, then run the following command.

$ sudo type -a csh

/bin/csh

3. Verify New Shell

The /etc/passwd contains login information about every user in your system. It also contains information about default settings for each user. You can use grep command along with your username to find out the default shell for that user.

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

ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/csh

In this article, we have learnt how to reset default shell in Linux.

Originally published at https://techosha.com/how-to-change-default-shell-in-linux/

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
How to Change Default Shell In Linux by Techosha - Issuu