23

I want to change my shell from bash to zsh.

I have tried running the following while logged in as user zol:

$ chsh -s /bin/zsh
$ sudo chsh -s /bin/zsh zol
$ su -c 'chsh -s /bin/zsh zol'
# The above all results with:
$ password:
$ chsh: Shell not changed.

# zsh exists in /etc/shells.. 
chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/zsh

What could be wrong? How can I fix it?

  • Did you try running 'chsh' without any arguments as zol? – George M Jun 2 '12 at 14:48
  • Are you using something like ldap/nis etc.? – Ulrich Dangel Jun 2 '12 at 14:53
  • Much more importantly: Why doesnt it give you more info? That message might be fine for a seasoned sysop but for most people it's downright rude. Im facing the same problem 5 years on, and people wonder why linux has spent the past 20 years not on the desktop. – flurbius Sep 4 '17 at 12:26
  • You expected your shell to change instantly? You change your login shell with chsh, which means you will have to log in again. – Kusalananda Nov 6 '19 at 17:02
20

User account modifications will not be saved if you have opened /etc/passwd (vim /etc/passwd) when you try to change the info.

Alternative: try with usermod (as zol):

$ usermod -s /bin/zsh 

or

$ sudo usermod -s /bin/zsh zol

If this doesn't work either, edit /etc/passwd by hand.

sudo vipw
# set zol's shell to /bin/zsh
:wq
| improve this answer | |
  • 6
    please use vipw instead of vim as they set the appropriate file locks. – Ulrich Dangel Jun 2 '12 at 15:06
  • "User account modifications will not be saved if you have opened /etc/passwd" — but why? – Thanatos Feb 3 '15 at 19:44
  • It doesn't work too. When I restart Linux virtual machine (centos7), it's OK now! – WeizhongTu Jul 11 '16 at 10:56
1

When to run "chsh -l" if you to see:

/usr/bin/zsh
/bin/zsh

Then use:

chsh -s /usr/bin/zsh

Warning: The commands was run on Fedora 25, In ubuntun the option "-l" from is out.

| improve this answer | |
  • -l is an invalid option for me. I'm on Ubuntu 16.04 – byxor Jul 27 '17 at 10:39
  • Sorry, I don't give information about the distro where the commands work. In my case I tested on Fedora 25. I try on ubuntu and I verify the option "-l" is out. – lourencoccc Jul 27 '17 at 13:18
  • Regardless, chsh -s worked perfectly. Thanks. – byxor Jul 27 '17 at 13:33
  • The option is valid on Manjaro but it still refuses to change the shell. – flurbius Sep 4 '17 at 12:28
1

Just ran into this. No matter what I did logging in and back out would not change my shell yet it was listed in /etc/shells and in /etc/passwd.

finally it dawned on me: Maybe I am logged in with another session?

So I did

# who

and it validated I did have indeed other open sessions from other machines:

dom  pts/0        Nov 6 13:53 (10.1.6.121)
dom  pts/1        Nov 5 12:30 (10.1.6.165)
dom  pts/2        Nov 4 12:33 (10.1.6.197)

I then did:

pkill -KILL -u dom

I was immediately logged out and after logging back in: Voila! Shell was changed

| improve this answer | |
0

If you see chsh: Shell not changed., it could mean that the shell was already changed.

Check which shell is listed:

cat /etc/passwd | grep `cd; pwd`

If it's correct, log out and back in to have the change take effect.

| improve this answer | |

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.