Howto: Changing Linux Login Shell

See all Bash/Shell scripting related FAQ
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 the /etc/passwd file to change your shell. Instead, use the chsh command. It changes the user login shell that sets the name of the users’ initial login command. A normal user may only change the login shell for their account. However, the superuser, i.e. root user, may change the login shell for any account.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category User Management
Prerequisites chsh command
OS compatibility AlmaLinux Alpine Arch BSD Debian Fedora Linux macOS Mint openSUSE Pop!_OS RHEL Rocky Stream SUSE Ubuntu Unix WSL
Est. reading time 2 minutes

chsh command syntax

Changing default shell in linux/unix
The following is syntax for the chsh command:
chsh -s {shell-name} {user-name}

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

First, find out available shell list using the less command/cat command/more command:
$ less /etc/shells
Sample Outputs:


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

To change your shell name to /bin/tcsh, type the following command and press the [Enter] key:
$ 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 using the type command or command command:
$ type -s bash
$ which bash

Here is what I see:

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 level access, then:
$ sudo chsh -s /usr/local/bin/bash vivek

Changing Linux Login Shell help

Use the following commands to get help about the chsh command using the help command or man command:
$ man chsh
$ chsh --help

Summing up

That is all for now. I hope this little tutorial helped you change your shell. If you need help, post the comment below or just post your appreciation note.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

6 comments… add one
  • Sutharsan Oct 9, 2009 @ 9:00

    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 Aug 27, 2011 @ 12:56

      yes, try the cron deamon (crontab)

  • Drey Jan 7, 2011 @ 8:28

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

  • homoudi Mar 18, 2014 @ 7:38

    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 Mar 18, 2014 @ 10:14

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

  • s Sep 29, 2016 @ 9:12

    chsh not working for centos

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.