19

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?

  • 11
    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/ – steeldriver Sep 21 '13 at 13:28
12

My computer is part of a network using 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.

  • 10
    can you explain what a "core machine" is? – Nerrve Jan 23 '14 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 Jan 23 '14 at 17:12
  • 4
    @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 Feb 23 '18 at 14:46
  • @Geek did you find the way how to solve it? – milushov Aug 12 at 23:05
11

There is a workaround for gnome-terminal:

  1. Go to Edit -> Profile preferences -> Title 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. – cacoder Apr 10 '18 at 20:24
  • This also works for Konsole and yakuake in KDE. – xgdgsc May 31 at 1:16
5

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

chsh

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 Jan 10 '14 at 19:31
4

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.

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

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.

  • 1
    One reason your user might not exist in /etc/passwd is if authentication is not handled on that machine (e.g. ldap) – MatrixManAtYrService Feb 23 '18 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.