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?

  • 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. – kos Mar 18 '16 at 6:58
up vote 14 down vote accepted

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.

  • One wonders how you fix this when root's shell is also zsh... LiveCD? – Kevin Mar 18 '16 at 4:20
  • @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. – kos Mar 18 '16 at 7:07
  • 3
    @Kevin Possibly with a boot option like init=/bin/bash. – immibis Mar 18 '16 at 9:43

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.

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!

  • 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.) – Peter Cordes Mar 18 '16 at 3:13

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.