Bash – Fix ‘Cannot Execute Help: No Such File or Directory’ Error with sudo su

bashroot

I installed zsh and changed root shell /bin/bash to /usr/bin/zsh. Then I rebooted and typed sudo su. It said "Cannot execute help: No such file or directory". So, I typed sudo bash. However, when I typed "echo $SHELL", it said the root shell is 'help'. How can I fix this?

Best Answer

The error message Cannot execute help: No such file or directory indicates that root's login shell has been set to help rather than to a valid shell.

You may fix this by issuing the correct chsh command:

sudo chsh -s /bin/bash root

or by editing root's login record in /etc/passwd. This file must be edited with vipw (never ever directly):

sudo vipw

On most Linux systems, root's entry in the file that opens up in the editor when you use vipw should look something like

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

You should make sure that the last :-delimited field is the correct path to the login shell for root on your system, and change it in the editor if it's not. Then save the file and exit.


Note that there is absolutely no benefit in changing the login shell of root, as you should not find yourself logging in as root or using an interactive root shell for any lengths of time.

Any administrational tasks that you may need to perform on the system may be performed using sudo followed by the command that you need to execute.

There is additionally no need to use su with sudo. This is discussed in the answers to the question Is there ever a good reason to run sudo su?

Related Question