A day before yesterday, I messed up my workstation by removing zsh from the system stupidly. If you too have made the same mistake, welcome my friend; I’ll be your savior.
Once I restarted the system, I’m not able to login back in. Every time I entered the right password and the system again asked for a password instead of showing my lovely desktop, what the heck happened? why I’m not able to see my Desktop?
Apparently, I tried to log in as tty by pressing Ctrl + Alt + F2, and the problem was the same. Now I’m stuck. What do I do now? How can I recover it? I’m not left with any options, and Suddenly my mind hit me to change the runlevel and try to resolve it.
Anyway, after that, I was able to restore it. If you are system behave like mine after removing zsh, please read the guide wisely.
Table of Contents
Steps to fix No login after removing zsh
The steps are quite easy First step change the system runlevel to 1 (runlevel like a stage by default workstation run on level 5 ) from the boot menu, and the second step is to replace zsh from /etc/passwd.
Step 1. Change runlevel from Boot menu
The initial step is to restart the system. When the grub menu appears, press ‘c’ and wait for the next screen to show up.
And move your cursor next to ro quiet and type 1 like the below image once you append, press Ctrl – x or F10 to boot the system in rescue mode.
If you follow the above instructions properly, your computer screen looks like the below image with the welcome message “You are in rescue mode.”
Undoubtedly enter the root password to revert the default shell.
Step 2. Replace zsh from /etc/passwd to bash
Well done, you have completed the first step. Now open /etc/passwd using your favorite text editor. In Debian, you will not be allowed to use vim editor. So choose nano editor to modify a file.
# nano /etc/passwd
Find the two lines starting with the root and second your username like the one below snippet:
And replace zsh with bash.
Step 3. Reboot system into default mode
Our work is done over here, Now back to the default run-level to check the changes. To reboot your system, type the below command:
# systemctl default
That’s all to fix the login issue after removing zsh from Debian/Ubuntu or any other Linux Distribution. Next time whenever you change the shell, use the chsh command to avoid any disruptions.
If you want to share something about a login error that I missed or know something that would help others, please share that in a comment section.
If you want to say Hi to me or want to suggest something feel free to contact me.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.