Can't open shell after changing default shell
Solution 1
To get back into the system you can boot into single user mode by appending the number 1 at the end of the linux kernel line within GRUB. The method for doing this is roughly outlined in this U&L Q&A titled: Can I launch a process as root without launching root's login shell?.
Once you've done this you'll be dropped to a prompt as root from where you'll be able to reverse the changes you made to your shell. This will get your system back so that it's working correctly.
From here you'll likely want to run chsh
for your username instead of whatever method you employed previously.
Solution 2
Login as root
. Verify that zsh
is installed. If not apt-get install zsh
Solution 3
There are two reasons why you might not be able to open a terminal or log in in text mode: either your shell (as recorded in the user database) doesn't exist, or your shell's configuration file conks out on a fatal error.
If chsh
succeeded then your shell does exist (chsh
checks that the shell is in an allowed list, and Ubuntu's package management updates the list based on installed packages). So unless you removed the zsh
package after doing chsh -s zsh
(in which case you should just reinstall it), we can rule this case out.
Thus one of the configuration files that you got from Prezto must be buggy, incorrectly installed, or missing some critical dependency. Move these configuration files out of the way. Launch a file manager such as Nautilus and rename the following files in your home directory (if they exist): .zlogin
, .zlogout
, .zprofile
, .zshenv
and .zshrc
. If they're symbolic links, just remove the symbolic links and you'll recreate them later.
Once you've done that, you'll be able to open a terminal and start using zsh with its default configuration. The first time you run zsh, its new user setup interface will run (you must have seen it already if you followed the instructions in https://github.com/sorin-ionescu/prezto).
Change your shell back temporarily to bash (chsh -s bash
) until you sort out the problem with Prezto. Open a terminal (now running bash), and run zsh
. Move the .z*
files back into place, or re-create the symbolic links following step 3. Now run zsh
in this open terminal and see what the errors are. If the errors aren't informative, run zsh -x
to get a debug trace.
Once you've solved the problem and zsh starts, run chsh -s zsh
again.
Related videos on Youtube
vpshastry
Updated on September 18, 2022Comments
-
vpshastry over 1 year
I changed my default shell to zsh from bash in Ubuntu. I used the steps explained in http://github.com/sorin-ionescu/prezto and ran
chsh -s zsh
. After this, I couldn't able to log in to any shell as it pops out as soon as I try to login. I tried from gnome terminal, xterm and trying to log in from tty1 (Alt+Ctrl+F1). It closes as soon as I try to open.-
Graeme almost 10 yearsPossibly a bug in your
.zshrc
(or.zshenv
) that is causing it to exit? -
Stéphane Chazelas almost 10 yearsHow did you change your shell? with chsh, by modifying /etc/passwd? Is the path you entered there mentioned in /etc/shells? Anything in /var/log/auth.log, What happens if you
su your-username
from root? -
vpshastry almost 10 yearschsh -s zsh. Used the steps explained in github.com/sorin-ionescu/prezto. @stephane I can't even get to a prompt to execute any command.
-
Graeme almost 10 years@Varun, the easiest way to get a shell is probably just to log in as another user (you could even create one via the desktop environment).
-
-
Graeme almost 10 yearsOn Ubuntu, the root login is disabled by default.
-
Stéphane Chazelas almost 10 years@Graeme, I believe that in Ubuntu, you can login as root using the "recovery boot option".
-
Chad K almost 10 years@Graeme there are ways around that
sudo su -
-
Graeme almost 10 years@Creek, for which you need to be able to start a shell...
-
Chad K almost 10 years@Graeme touche...