19

i want to change default shell env

and run chsh -s /bin/zsh as root user,

but a error message appeared: chsh: PAM authentication failed.

i find this thread http://ubuntuforums.org/showthread.php?t=1702833

but the answer did not solve my problem

any help would be appreciated


this is the content of /etc/pam.d/chsh

#
# The PAM configuration file for the Shadow `chsh' service
#

# This will not allow a user to change their shell unless
# their current one is listed in /etc/shells. This keeps
# accounts with special shells from changing them.
auth       required   pam_shells.so

# This allows root to change user shell without being
# prompted for a password
auth            sufficient      pam_rootok.so

# The standard Unix authentication modules, used with
# NIS (man nsswitch) as well as normal /etc/passwd and
# /etc/shadow entries.
@include common-auth
@include common-account
@include common-session

this is the content of /etc/shells

# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/tmux
/usr/bin/screen
/bin/zsh
/usr/bin/zsh

i find that i used to run chsh -s zsh this will change first line of /etc/passwd as

root:x:0:0:root:/root:zsh

and chsh will ask for password whaterver you try

i just edit /etc/passwd file manually, and everything is ok.

stupid mistake and thanks for your replies

2
  • Can you provide your /etc/pam.d/chsh ? (BTW it's generally considered a good idea for the root login shell to be minimal / stable - is there areason you want zsh as the default shell rather than starting it after login?)
    – symcbean
    Apr 19 '13 at 11:17
  • i just want to auto-enter zsh shell when i was just logged in, maybe this is not good.
    – txworking
    Apr 22 '13 at 5:02
5

Check your /etc/shells file and add /bin/zsh to file if this line does not exists.

3
  • 4
    this answer inspired me to check /etc/passwd file whether i input the correct format of shell name. Thx
    – txworking
    Apr 22 '13 at 8:10
  • For me, using a vagrant VM, I needed to change /etc/passwd. Thanks @txworking!
    – wulftone
    Nov 4 '14 at 23:19
  • For me, the issue is called by an erroneous configuration for shell inside /etc/passwd for the root account...
    – taper
    Oct 13 '19 at 21:32
5

Check your /etc/passwd. In my case I had specified an invalid shell with chsh previously and that's what was causing the problem.

I changed it from zsh as the shell to /bin/zsh and that made the problem go away for me.

4

You must run your code as sudo:

sudo chsh -s /bin/zsh

I had same problem too, and it worked!

1
  • Won't this change the root user's shell?
    – mortal36
    Sep 26 '20 at 3:08
2

I faced the same problem. whenever i typed in chsh it use to prompt

chsh: PAM authentication failed

But I solved it by doing some modification in the /etc/passwd file

Users of kali-linux

just open your root terminal and modify /etc/passwd file you can use pico,nano,or vi editor for this job i am going by vi

vi /etc/passwd

then search for the user account. and change the shells to your desired shell make sure the desired shell in installed in your distros of linux for new user to see what shells are present in their linux just type in

cat /etc/shells

it lists them there .If at all you have install the shell and you are unable to see it in /etc/shell you need to create a link and place path of shell say for suppose /bin/ksh in /etc/shells file manually...

for example you are in bash and you want to change it to ksh

just go to account in /etc/passwd file and in the last field edit

/bin/bash to /bin/ksh or /bin/ksh93 (as in your cat /etc/shells)

just logout and login and you are good to go...

for users of other distros (say) ubuntu

type in

sudo -H gnome-terminal (to get a root terminal)

and the process is same as above as you too have root terminal like a kali-linux user..

1

Looks like your path my be wrong. To check it:

[nick ~]$ which zsh
/usr/bin/zsh

If the result is /usr/bin/zch, this should do the trick:

[nick ~]$ chsh -s /usr/bin/zsh

*edit for typo.

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.