How To Fix A Damaged Ubuntu OS Without Reinstalling From Scratch

These instructions are copied from Senthil Kumar’s article at https://ostechnix.com/how-to-fix-broken-ubuntu-os-without-reinstalling-it/ which has saved me a great amount of time and grief, as I continue to learn Linux and periodically ruin my operating system trying new things.  Just as he says in his article, as soon as you can access your system well enough to make backups of your data do that before continuing to use the system as normal.  If you make it a habit to keep most of your files in your home directory, with a text file containing notes on any steps that you had to follow to get your particular computer working, then if you do have to do a complete reinstall again it will be much easier as you can just drop your files back in to your home directory and follow your text file of installation instructions that you’ve made.

And now for the instructions, I am keeping this here for my own reference and for others that may need to find it, and you may find more of the original author’s articles on Linux at https://ostechnix.com/author/sk/ .


Repairing a Damaged Ubuntu Linux OS

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. 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. Now reboot the system using command:

$ sudo reboot

You should now be able to login to Ubuntu as usual.

After I followed these steps, all of the data in my Ubuntu system was intact and everything was in the same way as I left it.

This method may not always work, however this small tip worked for me and saved time by not having to reinstall my Ubuntu system from scratch.

End of Article.

Leave a Reply