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?
1 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?
-
1So the questioner did not change the superuser's login shell to the Z shell as the question claims, but at one point ran
chsh -s help
instead ofchsh --help
. For more on the subject of changing the superuser's login shell, see unix.stackexchange.com/questions/2640 .– JdeBPCommented Feb 8, 2018 at 6:56 -
I had same problem but instead of help, it was showing virsh: No such file or directory.– UNREALCommented Mar 7 at 3:16
-
But I saw history , I didnt write some chsh command, I did write csh then virsh, I was just exploring different shell– UNREALCommented Mar 7 at 3:28
-
But I saw history , I didnt write some chsh command, I did write csh then virsh, I was just exploring different shell– UNREALCommented Mar 7 at 3:28