Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to Linux and using Debian 7. I was using bash, but tried out zsh by using chsh. Initially probably entered a bad shell name but eventually switched to zsh successfully.

Now I switched back to bash but can't access root

When I hit su and the password it returns "Cannot execute zsh: No such file or diretory", while apparently I'm using bash.

Additionally, when I changed back to zsh it still said the same, "can't execute zsh ..."

Can someone help please?

Thanks!

violeaf

share|improve this question
    
Have you tried creating a new shell? Close your terminal program and reopen it. You could alternatively just type 'bash'. – spuder Aug 22 '13 at 1:54
    
If you mean using another shell other than bash or zsh then I haven't, but will give it a go and let you know. Thanks! By the way I'm using the GNOME terminal. – violeaf Aug 22 '13 at 6:49
    
Did you chsh to zsh for both your non-root account as well as the root account and later uninstalled zsh? It sounds like your root account still uses zsh and that you only switched your non-root account back to bash. – Adrian Frühwirth Aug 22 '13 at 6:52
    
You might have chsh'd your root shell to just zsh (without path) instead of /bin/zsh (but chsh should have warned you about that) in which case it cannot find the shell. – Adrian Frühwirth Aug 22 '13 at 6:55
    
Adrian I think this may well be the case. How can I now chsh the root shell back? Tried Tommi's suggestion but didn't work. Any idea? – violeaf Aug 22 '13 at 19:13
up vote 0 down vote accepted

This is why you want to always stay logged in in a second terminal while you muck with your login settings.

As for recovery after locking yourself out: Since you have physical access just boot from a live cd, then mount the system partition on your disk, and edit /etc/passwd manually. Or reboot, go to the grub prompt, and add init=/bin/sh to your kernel command line.

share|improve this answer
    
Thanks @vbraun, before everything I had to navigate to /bin before I was able to get root access under zch. Then instead of using a live cd I sudo'd gedit the passwd and changed the shell value to /bin/bash wherever it appears, now it seems to work. Thanks again for all your help – violeaf Aug 22 '13 at 23:59

su -s /bin/sh -c chsh root

And this time make sure you provide full path.

share|improve this answer
    
Tommi I typed this in and my password, but got 'Cannot execute zsh' – violeaf Aug 22 '13 at 19:09
1  
simply doesn't work, this is stupid. – mpgn Jan 23 '14 at 23:32
    
Care to elaborate why you think it's stupid? If he had /bin/zsh listed in /etc/shells (which I'm assuming is the case here), then the -s will work with su. I even made sure it works by first switching my root (who uses /bin/zsh by default) to use /bin/bash. Then I moved /bin/bash to /bin/bash.disabled. Failed to login as root as described here. Ran the exact above command I posted and was able to change shell back to my default inspite of what root had for him in /etc/passwd. – Tommi Kyntola Feb 5 '14 at 9:45

type $ sudo bash it ask for password enter password then type

cd /etc (press enter)

type # nano passwd press enter thn change ur passwd file (replace zsh wit sh)

share|improve this answer

You must log in to answer this question.

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