≡ Menu

Howto: Changing Linux Login Shell

I am a new Linux user and can you tell me a command name to change the default login shell in Linux or UNIX operating system?

You don’t have to edit /etc/passwd file to change your shell. You need to use the chsh command. It changes the user login shell. This determines the name of the users’ initial login command. A normal user may only change the login shell for his/her own account, the super user i.e. root user may change the login shell for any account.
Changing default shell in linux/unix

chsh command syntax

Following is syntax for chsh command:
chsh -s {shell-name} {user-name}

  • -s {shell-name} : Specify your login shell name. You can obtained list of avialble shell from /etc/shells file.
  • User-name : It is optional, useful if you are a root user.

First, find out available shell list:
$ less /etc/shells
Sample Outputs:


Example: Changing default shell in Linux to /bin/tcsh

To change your shell name to /bin/tcsh:
$ chsh -s /bin/tcsh
Sample outputs:


When promoted for password, type your own password. You must log out and log back in to see this change. If you just type chsh command, it will prompt for shell name interactively:
$ chsh
Sample outputs:

Changing the login shell for tv
Enter the new value, or press ENTER for the default
       Login Shell [/bin/bash]:

This command will change the default login shell to /bin/tcsh permanently. In this example, first find out path for bash shell, enter:
$ type -s bash
$ which bash

Sample outputs:

bash is /usr/local/bin/bash

Now use the below command to set shell to bash for a user named vivek:
$ chsh -s /usr/local/bin/bash vivek
OR if you know sysadmin root passoword:
$ sudo chsh -s /usr/local/bin/bash vivek

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 6 comments… add one }
  • Sutharsan October 9, 2009, 9:00 am

    I need to change my root password on daily basis. But the new password should be create from shell script. The input for the new password should be current date. Which means

    let we say
    the current date is x1, then the password should be x2. (but user should be able to calculate the new password)

    is it possible to do it?

    • max August 27, 2011, 12:56 pm

      yes, try the cron deamon (crontab)

  • Drey January 7, 2011, 8:28 am

    Followed, but still see csh welcome in new tab of Terminal in xfce on FreeBSD.
    /etc/passwd shows bash. What I’ve missed?

  • homoudi March 18, 2014, 7:38 am

    please i try to change my shell from bash to csh then i get this steps ,what have i write then:
    [wrf@wrf-host ~]$ chsh
    Changing shell for wrf.
    New shell [/bin/csh]:

    • Drey March 18, 2014, 10:14 am

      You should then just press [enter] to have csh as a default shell.

  • s September 29, 2016, 9:12 am

    chsh not working for centos

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , ,