I've switched my bash to zsh in root using chsh -s /usr/bin/zsh root

After when I change back to bash, I type the wrong path: chsh -s /usr/bin/bash root

Now I cannot enter root and I get this prompt, how can I reset it?

user@ip:~$ sudo su
Cannot execute /usr/bin/bash: No such file or directory

Type the following->

sudo -s

Enter your admin password. The prompt should now end in #. Enter->

chsh -s /bin/sh root

and exit the "root" shell and test.

  • 1
    Running sudo chsh -s /bin/sh root should work as well. – nohillside Jun 11 at 17:49

As the error message indicates, you have set the wrong path for bash. bash is located at /bin/bash, not /usr/bin/bash.

On some distros, /bin/bash may be a symlink to /usr/bin/bash, but this is NOT what macOS does. (I never said macOS is a Linux distro. I'm just saying the symlink behaviors are different. Please.)

Use the following command to set shell as Bash for root correctly.

sudo chsh -s /bin/bash root

The default shell for root user is /bin/sh, if you wanna reset it,

sudo chsh -s /bin/sh root
  • macOS is not a (Linux) distro :-) – nohillside Sep 12 at 5:18
  • @nohillside I know that, I was just pointing out the symlink behaviors are different, which may be the reason why the questioner set a wrong path. – Simba 7 hours ago

You must log in to answer this question.

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