3.2 KiB
How To Fix Broken Ubuntu OS Without Reinstalling It
Today, I was upgrading my Ubuntu 18.04 LTS system. Unfortunately, the power has gone in mid-way and the system powered off while updating Ubuntu OS. When the power is back, I boot the system again. Right after entering the password at the login screen, it’s gone blank and didn’t respond. Keyboard and mouse also didn’t work. All I see is just a blank screen! Thankfully, It’s just a test machine and there were no important data in it. I can simply wipe off the entire OS and install it again. But, I don’t want to do that. Since I have nothing to lose, I just wanted to repair my broken Ubuntu system without reinstalling it completely and it worked!!! If you ever find yourself in a situation like mine, don’t panic. This brief tutorial describes how to easily fix broken Ubuntu OS without losing data and without reinstalling it completely.
Fix Broken Ubuntu OS
First of all, try to login with live cd and backup your data in an external drive. Just in case, if this method didn’t work, you can still have your data and reinstall everything!
At the login screen, press CTRL+ALT+F1 to switch to tty1. You can learn more about switching between TTYs here.
Now, type the following commands one by one to fix the broken Ubuntu Linux.
$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/lib/dpkg/lock-frontend
$ sudo dpkg --configure -a
$ sudo apt clean
$ sudo apt update --fix-missing
$ sudo apt install -f
$ sudo dpkg --configure -a
$ sudo apt upgrade
$ sudo apt dist-upgrade
Finally, reboot the system using command:
$ sudo reboot
You can now be able to login to your Ubuntu system as usual.
After I followed these steps, all of my data in Ubuntu 18.04 test system was there and everything is the same as I left it. This method may not work for everyone. However, this small tip worked for me and saved a couple minutes from reinstalling. If you know any other better way, please let me know in the comment section. I will add them in this guide as well.
And, that’s all for now. Hope this was useful.
More good stuffs to come. Stay tuned!
Cheers!
via: https://www.ostechnix.com/how-to-fix-broken-ubuntu-os-without-reinstalling-it/