6

I tried to change root's shell with chsh command, but now I get an error when I try to connect as root with sudo -i.

$ sudo -i
sudo: /usr/bin/bash: command not found

What do I have to modify to get the bash shell?

wjandrea
  • 14,109
  • 4
  • 48
  • 98
Sandra Ross
  • 777
  • 3
  • 10
  • 20

1 Answers1

12

Assuming that you have not modified the path or created symlink, the default path to the bash binary is /bin/bash, not /usr/bin/bash.

The error is occurring because you have set the root's shell as /usr/bin/bash in /etc/passwd like:

root:x:0:0:root:/root:/usr/bin/bash

You need to change that to /bin/bash:

sudo usermod -s /bin/bash root

or do:

sudo vipw

and make the modifications manually.

You can obviously choose any other shell of your choice, just make sure that the path is correct. A common place to look for shell paths is /etc/shells file which contains the full paths to all the valid login shells on the system.

wjandrea
  • 14,109
  • 4
  • 48
  • 98
heemayl
  • 90,425
  • 20
  • 200
  • 267
  • Thanks for your answer. In the same time, I noticed I could modify the path with `sudo emacs /etc/passwd` – Sandra Ross Nov 30 '16 at 03:40
  • 4
    @SandraRoss If you are confident you can obviously do that. But i would suggest `vipw` as it will do the sanity checkings (e.g. syntax) over the changes to make sure everything is in place. – heemayl Nov 30 '16 at 03:43
  • 1
    If you don't want to usse vipw, you can check the integrity of /etc/passwd with pwck – ohno Nov 30 '16 at 09:00