How to reset default shell for root from user space
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.
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 Linux distros, /bin/bash
may be a symlink to /usr/bin/bash
, but this is NOT what macOS does. There's no /usr/bin/bash
on macOS, just /bin/bash
.
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