16

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?

tubu13
  • 291

5 Answers5

22

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.

kos
  • 41,268
2

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!

tubu13
  • 291
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.

1

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.

EThaiZone
  • 131
0

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.