Home Ubuntu How To Fix Broken Ubuntu OS Without Reinstalling It

How To Fix Broken Ubuntu OS Without Reinstalling It

A Working Solution To Repair Ubuntu Without Losing Data.

By sk
Published: Updated: 319.6K views

Just in case if your Ubuntu system is crashed due to power failure or network connectivity issue in the middle of the Upgrade process, you might end up with broken Ubuntu Linux. In such cases, you can easily fix broken Ubuntu OS without reinstalling it from scratch. Furthermore, you can accomplish this without the risk of data loss, as explained in the following instructions.

Introduction

Today, I was upgrading my Ubuntu LTS system. Unfortunately, the power has gone in the middle of the upgrade process and the system is powered off abruptly while the packages are still being upgraded.

When the power is back, I proceeded to boot up the system again. However, after entering the login password in my Ubuntu system, the screen went blank and became unresponsive. Neither the keyboard nor the mouse were functioning.

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 Ubuntu again.

But, I don't want to do that. Since I got nothing to lose, I just wanted to repair my broken Ubuntu system, without losing data and also without reinstalling it completely. To my luck, it worked!!!

Now let us see how to recover the broken Ubuntu Linux system, without reinstalling it.

Fix Broken Ubuntu OS Without Reinstalling It

1. First of all, try to login with live cd and backup your data in an external drive. Just in case, if this tutorial didn't work, you can still have your data and reinstall everything!

2. After successfully backing up your data, restart the system and log in as usual. At the login screen, press CTRL+ALT+F1 to switch to tty1. You can learn more about switching between TTYs here.

3. 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

4. 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, I managed to successfully fix broken Ubuntu 22.04 without reinstalling it. And also, all the data in my Ubuntu system were intact and everything was in the same way 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 my Ubuntu system from scratch.

If you know any other better way, please let me know in the comment section. I will add them in this guide as well.

You May Also Like

71 comments

max July 23, 2023 - 2:53 pm

Thanks a lot dude, it wokrs for me.

Reply
jv August 27, 2023 - 12:28 am

Dear friend! Your guide helped me immensely. I was trying to upgrade to Ubuntu 20.04 with Software Updater. The upgrade failed due to some packages I had installed and I was worried I would had to perform clean install, losing all my custom settings. But with your help, my computer is up and running again. Thanks again and stay well.

Reply
sk August 28, 2023 - 10:53 am

Glad it worked out for you! Happy to help.

Reply
1 4 5 6

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More