9

I tried to change my user's shell, but used "sudo chsh", and changed the root shell to "bash" instead of "/bin/bash". Now when I try to change it I get "chsh: PAM authentication failed" and it seems like other things aren't working, either.

~$ sudo su
Cannot execute bash: No such file or directory

This happens with recovery mode, too. What do I do to change it to something usable?

4 Answers 4

17

If you are able to login using your regular user, just change the root users shell directly:

sudo gedit /etc/passwd

Find the line for you root user, usually the first one, and change the last part from

...:bash

to

...:/bin/bash

And you should be good to go.

(NB: Replace gedit with whatever editor you fancy.)

0
6

Use the Ubuntu install disk to boot the live session.

Mount the root ('/') partition on the harddisk (make sure it's writable).

edit '[HD mount point]/etc/passwd' (eg /media/sda1/etc/passwd),

root should be the first line, just correct the login shell which will be the last entry on the line.

Unmount harddisk. Remove CD. Reboot

1
  • 3
    This is "if you can't log in as your regular user"
    – Broam
    Commented May 25, 2010 at 13:38
2

I played with this once ages ago:

cd /bin ; sudo su

What's happening is without a / in front the shell is being interpreted as a relative path. Oh gee if we are in /bin it resolves correctly.

If you get really stuck; the rescue CD is the long way around. The boot option init=/bin/sh gives you a root shell immediately. The cursor just blinks at you with no prompt but you have a root shell. Do

set -i
# mount / -o remmount,rw
# vi /etc/passwd
<fix it>
# mount / -o remount,ro
# reboot -f
1

Note, as a short-term work-around, you can use the "-s" switch on the su command to specify a shell. For example:

su -s /bin/bash

would start your su session with the /bin/bash shell. Same goes for sudo su -s /bin/bash (or whatever shell you'd like) @Bjarke Freund-Hansen's answer is the permanent fix.

2
  • I've just found out yesterday this doesn't work. If the current shell for the target account isn't in /etc/shells, su ignores -s unless the caller is already root.
    – Joshua
    Commented Jan 20, 2019 at 23:08
  • Did you try putting sudo in front of the su like the original question does? Commented Feb 13, 2019 at 8:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .