82

This question already has an answer here:

I have a Ubuntu Server VPS and I want to use /bin/bash/ as my shell. How can I change my shell? I have root access but I don't work as root. So dash is my default shell now.

I have read How do I make Bash my default shell on Ubuntu? and chsh seams to be the preferred way to go. But when I type chsh /bin/bash I get this message: chsh: unknown user /bin/bash

And if I just type /bin/bash the Bash shell seams to work fine. How to change it?

marked as duplicate by Heptite, Garrett, random Mar 8 '14 at 13:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

79

To change a shell, use the bare chsh command. This will prompt you for the new shell. You do not have to run anything as root.

  • Ah, that was even better! – Jonas Mar 12 '10 at 20:19
  • 8
    don't forget to log out and log back in to see the change. – hangtwenty Jul 3 '13 at 12:23
  • 24
    Doesn't work as normal user: $ chsh You may not change the shell for 'user'. – Henning May 1 '14 at 20:00
  • 1
    Works for me. Sounds like your system has been deliberately locked down. – Michael Cole Feb 25 '16 at 21:22
  • 1
    I use ssh, but chsh asks me for password which I don't know. Any way to work around this? – Qwerty Apr 28 '16 at 13:25
107

When running as root, you can use chsh to change other users shells. The syntax you want to use it this. You can change your own shell without root rights.

chsh -s /bin/bash username

  • 10
    -1 chsh does not need to be run as root to change your own shell. Changing others' shells requires root. – Broam Mar 12 '10 at 17:25
  • 2
    This worked. I always get the "You may not change the shell for ..." error message. – setzamora Jun 18 '17 at 21:30
  • 2
    Logout and log back in after to observe the change – smac89 Nov 27 '17 at 9:26
  • 1
    +1 I found this to work, after trying chsh command when logged in as the user and getting "You may not change the shell for ..." – therobyouknow Sep 19 '18 at 11:57
49

You can change your default shell for your user by using the usermod command.

sudo usermod -s <shell> <username>

replace with the name of the shell you want to use (i.e. /bin/bash) and with the username for which you want to change it.

This will set the default shell for the username selected in the /etc/passwd file.

  • 8
    Use usermod if you see "chsh You may not change the shell for..." – Xeoncross Jun 27 '16 at 23:22
  • 2
    voting up, since chsh didn't work for me indeed. Thanks! – Mixaz Dec 8 '16 at 19:46
  • Important to note that usermod requires sudo – ARun32 Jul 4 '17 at 22:00

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