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?
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.
There is a workaround for
gnome-terminal
:bash
as the Custom command (orfish
, or anything).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, bygetent 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:
Source: User does not exist in /etc/passwd when trying to change the default shell.
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"
or
ssh my-host -t "cd /data/repos; zsh --login"
If you also want to login directly into a different working dir.
Edit:
Another simple option that does not require ssh command manipulation:
vi ~/.profile
zsh
:wq
)This solution also has the advantage that it persists when creating new sub-shells, for example when using
tmux
.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
: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:
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:See also: Understanding /etc/passwd File Format.
This answer helped me.
In your
~/.profile
addOr whatever other shell you want to use
Open the file ~/.bashrc and add this at the end :
Don't forget to configure zsh :
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