ZSH removed, cannot relogin

12,402

Solution 1

The guest user is not granted the permission to run sudo or pkexec, which (unless you're root, which you're not) are required in order to change another user's shell.

So the only solution occurring to me is booting into a root shell and changing the user's shell as root:

chsh -s /bin/bash user

Where user is your user's username.

Solution 2

Login as root or boot into root shell and edit the shell entry in /etc/passwd to "/bin/sh". Then you can login again as yourself and change things from there.

Solution 3

So additionally to what @kos said..

For some reason I added source ~/.profile to my .bashrc file (don't know why.. read it somewhere) And my .profile file loaded the .bashrc which cause circular loading!.

Removing the source.. + @kos solution did the trick!

Solution 4

For who that have the problem from uninstalling zsh. Try this follow steps.

  1. Login as root via recovery mode. You can look how to do it at this answer. https://askubuntu.com/a/92558/104228
  2. After you log in as root. Open /etc/passwd. Find your user entry and change from /usr/bin/zsh to /bin/sh. Save file and reboot as the normal step. You should log in normally.
  3. After you reboot your ubuntu. You will found your shell look so bad. Run this command chsh -s /bin/bash. Type your password and enter. You shell will look good right now.
  4. Type sudo apt-get purge --auto-remove zsh to clean another dependency packages of zsh.

I hope this step will help another who have the same problem as me.

PS. My English is not the primary language. I hope you can understand me.

Share:
12,402

Related videos on Youtube

tubu13
Author by

tubu13

Updated on September 18, 2022

Comments

  • tubu13
    tubu13 over 1 year

    So I have install zsh and I didnt like it. so I did apt-get remove zsh

    From that point I cannot relogin, i click my user.. and then it just go back to the login screen. I can only login with the Guest session.

    I think the problem is caused because the defualt shell on my user is zsh and it doesnt exists anymore..

    How can I reinstall it from the guest session of change my users default shell for guest user?

    Even trying to loging with ctrl+alt+f2/6 i type my user and password. login is success but i the thrown back to the login.

    Any ideas?

    • kos
      kos about 8 years
      On a second thought the shell problem likely had no bearing. No user shell is spawned after the DM has been loaded before the DE is loaded (and that probably wouldn't have been a problem either). And I'm not sure about the ~/.bashrc - ~/.profile loop either: I've tested both purging the user's shell and creating the ~/.bashrc - ~/.profile loop in a VM and I've always been able to login through LightDM, though I've not been able to login through the console with the ~/.bashrc - ~/.profile loop (but still, LightDM instead worked). In any case you should unaccept my answer.
  • Peter Cordes
    Peter Cordes about 8 years
    Linux desktops have kind of broken the .profile-for-env-vars and one-per-login stuff / .bashrc-for-aliases paradigm. Since you sometimes need env vars set for stuff to work, I can see why one might think it's a good idea to source ~/.profile from .bashrc. (Logging in to a desktop session might not source your profile to set env vars for all children of the session.)
  • Kevin
    Kevin about 8 years
    One wonders how you fix this when root's shell is also zsh... LiveCD?
  • kos
    kos about 8 years
    @Kevin This answer is likely wrong. The shell has no bearing with the user not being logged in into the DE, as no user shell is spawned after the DM has been loaded befor the DE is loaded. I don't know if there are better options in case one manages to lock themself out that way, but I suppose that using a Live DVD and changing /etc/passwd manually should work.
  • user253751
    user253751 about 8 years
    @Kevin Possibly with a boot option like init=/bin/bash.
  • Nishant Kumar
    Nishant Kumar about 2 years
    hey thanks, you saved my ass