Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

What could be wrong? How can I fix it?

share|improve this question
Did you try running 'chsh' without any arguments as zol? – uther Jun 2 '12 at 14:48
Are you using something like ldap/nis etc.? – Ulrich Dangel Jun 2 '12 at 14:53
up vote 9 down vote accepted

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 


$ 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
share|improve this answer
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 at 10:56

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


Then use:

chsh -s /usr/bin/zsh
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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