How can I change shell in Ubuntu?

92

23

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?

Jonas

Posted 2010-03-12T15:12:47.930

Reputation: 21 007

Question was closed 2014-03-08T13:17:40.020

Answers

88

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.

Teddy

Posted 2010-03-12T15:12:47.930

Reputation: 5 504

Ah, that was even better! – Jonas – 2010-03-12T20:19:27.027

1Works for me. Sounds like your system has been deliberately locked down. – Michael Cole – 2016-02-25T21:22:39.457

1I use ssh, but chsh asks me for password which I don't know. Any way to work around this? – Qwerty – 2016-04-28T13:25:05.800

+1 @Henning I found chsh -s /bin/bash web to work, as in the answer below from Dentrasi. I can now use tab file/folder path autocomplete at the terminal with my new non-root user (as this is setup in the.bashrc file in the user's home directory, I believe (find it with ls -al)

– therobyouknow – 2018-09-19T11:55:31.117

8don't forget to log out and log back in to see the change. – driftcatcher – 2013-07-03T12:23:23.043

26Doesn't work as normal user:

$ chsh You may not change the shell for 'user'. – Henning – 2014-05-01T20:00:37.577

122

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

Dentrasi

Posted 2010-03-12T15:12:47.930

Reputation: 10 115

10-1 chsh does not need to be run as root to change your own shell. Changing others' shells requires root. – Broam – 2010-03-12T17:25:09.563

2This worked. I always get the "You may not change the shell for ..." error message. – setzamora – 2017-06-18T21:30:59.900

2Logout and log back in after to observe the change – smac89 – 2017-11-27T09:26:37.500

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 – 2018-09-19T11:57:44.000

54

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.

txwikinger

Posted 2010-03-12T15:12:47.930

Reputation: 2 467

10Use usermod if you see "chsh You may not change the shell for..." – Xeoncross – 2016-06-27T23:22:57.977

2voting up, since chsh didn't work for me indeed. Thanks! – Mixaz – 2016-12-08T19:46:59.147

Important to note that usermod requires sudo – ARun32 – 2017-07-04T22:00:40.407