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, 2016 at 6:58

5 Answers 5


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, 2016 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, 2016 at 7:07
  • 4
    @Kevin Possibly with a boot option like init=/bin/bash.
    – user253751
    Mar 18, 2016 at 9:43
  • hey thanks, you saved my ass Mar 16, 2022 at 3:19

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.) Mar 18, 2016 at 3:13

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.


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.


I had a problem finding my correct /etc/passwd file, to remove zsh from my root user so I can log back in, as previous answers correctly suggested.

I booted up using Rescue Mode, and in there, I was looking at /etc/passwd on rescue mode linux. This was undoubtedly wrong.

So I mounted my original linux (e.g. in /mnt/vdb1 or /mnt/sda1 for common cases), and looked into the /mnt/vdb1/etc/passwd file and found my original linux users, edited my root user shell, disabled Rescue Mode and was finally able to log back in as root. So:

Mount your linux partition, and look for /mnt/{mount_folder}/etc/passwd instead of looking for /etc/passwd on your Rescue Mode Linux.

Hope this helps someone.

You must log in to answer this question.

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