I want to change my default shell from tcsh to bash. So I tried and this is what happened:

>sudo chsh userid
Changing the login shell for userid
Enter the new value, or press ENTER for the default
        Login Shell [/xhbin/tcsh]: /bin/bash
chsh: user 'userid' does not exist in /etc/passwd

Indeed, I am not in /etc/passwd. I don't know why.

What can I do?

  • 14
    Is your system using distributed authentication (e.g. kerberos / winbind)? In that case your user details would not appear in the local /etc/passwd file (but should be visible using getent passwd <userid>). I think that whether running chsh is supported in that case may depend on settings in /etc/pam.d/ Commented Sep 21, 2013 at 13:28

10 Answers 10


My computer is part of a network using distributed authentication, so my user details would not appear in the local /etc/passwd file (but are visible using getent passwd userid) (thanks @steeldriver). In my case I had to do chsh on a core machine.

  • 23
    can you explain what a "core machine" is? Commented Jan 23, 2014 at 8:49
  • In my case I'm referring to a set of dedicated machines provided by the university inside their network that students can log into and use (shared). As opposed to my own machine in my office.
    – rmp251
    Commented Jan 23, 2014 at 17:12
  • 7
    @rmp251 This is exactly my scenario is. I don't have access to the core machine. Did you find a way to change the shell otherwise?
    – Geek
    Commented Feb 23, 2018 at 14:46
  • 5
    Better late than never. My workaround was to open my terminal preference, select the Unnamed profile, in the "Command" menu, check the box "Run a custom command instead of my shell" and type "/bin/zsh" as command
    – befabry
    Commented Sep 6, 2021 at 9:57
  • 2
    Being on an AWS WorkSpaces Linux machine, I had no access to the core machine but the instructions from @befabry worked perfectly. Thanks a bunch! :) Commented Jul 22, 2022 at 19:58

There is a workaround for gnome-terminal:

  1. Go to EditProfile preferencesTitle and Command.
  2. Check Run a custom command instead of my shell.
  3. Provide bash as the Custom command (or fish, or anything).
  • Thanks! Supplying a command to run immediately when I open my terminal (or new terminal tab) via the settings worked for me. Commented Apr 10, 2018 at 20:24
  • This also works for Konsole and yakuake in KDE.
    – xgdgsc
    Commented May 31, 2019 at 1:16
  • Great Answer. I was looking for ways to make zsh as my default one, and the other solutions was to edit the /etc/passwd file, which was not a good thing. This works like butter.
    – chmodsss
    Commented Apr 12, 2022 at 20:37
  • Thank you! This fixed my issue with AWS Workspaces Ubuntu machine.
    – John Doe
    Commented Mar 6 at 15:11

If you are trying to ssh into a remote host with a domain user, you might not be able to change your shell using chsh as @Masoud mentioned. But here is a simple workaround for this case - whenever you ssh into the machine, do this:

ssh my-host -t "zsh --login"


ssh my-host -t "cd /data/repos; zsh --login"

If you also want to login directly into a different working dir.


Another simple option that does not require ssh command manipulation:

  • Edit your profile file: vi ~/.profile
  • Launch your favorite shall by calling it at the last line, e.g. zsh
  • Save and quit (:wq)

This solution also has the advantage that it persists when creating new sub-shells, for example when using tmux.

  • Every time I need to exit the terminal session, I need to exit twice (one from zsh and once from bash). Is there any workaround for this issue? Edit: The workaround is to use this answer instead: askubuntu.com/a/1370050/749219
    – S P Sharan
    Commented Mar 31, 2022 at 15:06

If you are using LDAP authentication by PAM or something, you have to find your answer in your LDAP Server. Let's aim it for Microsoft AD, in which case your domain account is not in /etc/passwd when you log in, but you can see your user property in AD, by getent passwd | grep user.

If at the end it shows your shell is /bin/csh, that's because in your AD there is a attribute for that. So if you have administrator account on AD, you can fix it yourself. Otherwise just tell your AD admin to enable advance features in the View tab of Active directory users and computers > User properties > UNIX attributes. There you can change the login shell to /bin/bash.

Be sure you don't forget to run:

sudo /opt/pbis/bin/config LoginShellTemplate /bin/bash

Source: User does not exist in /etc/passwd when trying to change the default shell.

  • 2
    Question was to change shell for one user, whereas pbis config changes for all users.
    – kubanczyk
    Commented Aug 4, 2016 at 13:06

If you want to change the shell for your user, you do not need to become root. Just type:


without sudo and without arguments.

See also man chsh:

The chsh command changes the user login shell. This determines the name
of the user's initial login command. A normal user may only change the
login shell for her own account; the superuser may change the login
shell for any account.
  • The reason I used sudo was because it didn't do anything without it. > whoami userid > chsh You may not change the shell for 'userid'.
    – rmp251
    Commented Jan 10, 2014 at 19:31
  • The reason it works is that chsh does not work with kerberos Commented Sep 6, 2019 at 7:54
  • 2
    Still fails: chsh: user "walshcaadmin" does not exist.
    – Carl Walsh
    Commented Mar 17, 2021 at 19:25

My machine is using LDAP authentication and I don't have access to the server. So my workaround was to change $SHELL variable to zsh at the end of my .bashrc file. $SHELL=/bin/zsh $SHELL So for me when I open terminal bash opens zsh.


If you forgot your user name, you can use whoami command to remember you.

So, try with:

sudo chsh $(whoami)

If indeed, doesn't exist a line starting with your user name in /etc/passwd file (which seems inexplicable), you can add a new one like this:

username:x:1000:1000:your real name,,,:/home/username:/bin/bash

See also: Understanding /etc/passwd File Format.

  • 3
    One reason your user might not exist in /etc/passwd is if authentication is not handled on that machine (e.g. ldap) Commented Feb 23, 2018 at 16:55

Open the file ~/.bashrc and add this at the end :

# Run zsh
if [ "$SHELL" != "/usr/bin/zsh" ]
    export SHELL="/usr/bin/zsh"
    exec /usr/bin/zsh

Don't forget to configure zsh :

  • By typing "zsh" in a bash terminal.
  • Or by creating the file ~/.zshrc with default content

This answer helped me.

In your ~/.profile add

if [ "$SHELL" != "/bin/bash" ]
    export SHELL="/bin/bash"
    exec /bin/bash -l    # -l: login shell again

Or whatever other shell you want to use


the solution for active directory accounts is as follows:

$vim ~/.bashrc

and add this at the end :

if [ "$SHELL" != "/usr/bin/zsh" ] then export SHELL="/usr/bin/zsh" exec /usr/bin/zsh fi

  • Hello. How is this a answer to the question that was asked?
    – David
    Commented Apr 18, 2022 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .