Home FAQ How To Fix Broken Ubuntu OS Without Reinstalling It
Fix Broken Ubuntu OS Without Reinstalling It

How To Fix Broken Ubuntu OS Without Reinstalling It

By sk
8880 Views

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 while upgrading packages. When the power is back, I did boot the system again. Right after entering the login password in my Ubuntu system, 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 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 reinstalling it completely. To my luck, it worked!!! 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. In such cases, you can easily fix broken Ubuntu OS without reinstalling it from scratch, and without losing data.

Fix Broken Ubuntu OS Without Reinstalling It

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 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. If you know any other better way, please let me know in the comment section. I will add them in this guide as well.

Related read:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

39 comments

DFD December 10, 2018 - 6:59 pm

Not so long ago one would say Windows, instead of Ubuntu. The answer would be very similar: in the past, install Linux instead. Here, instead a real Linux distribution instead.

Reply
Mulya December 11, 2018 - 9:23 am

And what do you do if you can’t get the to login screen to access terminal (tty)?

Reply
sk December 11, 2018 - 11:34 am

Probably, I will use live cd or go to single user mode to see if I can fix it. I haven’t tried it yet though. Do you have any better way?

Reply
laddd44 January 7, 2019 - 10:53 am

does it work in offline mode pc??

Reply
sk January 7, 2019 - 11:38 am

Yes, It should work.

Reply
J April 5, 2019 - 9:45 pm

Thanks a lot, your list helped me also via an SSH connection from a remote PC. I needed to do it that way because the linux machine did not respond on CTRL+ALT+F1 to open directly tty1.

Reply
JEVBR April 25, 2019 - 6:34 pm

Thanks SK, that really solved my problem here. Saved my a lot of reinstalling all my programs (did have a backup). I messed up the installation process when at some point i opted for “show the difference” when asked if i wanted to update. At this point the installation went sideways. At the end i was not allowed to re-install before restarting, but the restart was locked (I guess i was deadlocked). Had to use the power button to restart.

Terminal is very useful, i use it a lot, but for most simple users, user-friendliness goes out the window as soon as terminal appears. Seems to me update process may need some reviewing

Reply
José Rosales June 21, 2019 - 7:11 am

Thank you this should be a marked post

Reply
Richy Doc August 13, 2019 - 3:01 am

Very good procedure. Save me a lot of time.
Thank.
Richard.

Reply
randy September 18, 2019 - 8:50 am

How can this work? If you used a usb stick to run the “live cd” and didn’t mount your linux partitions on the disk, then performing sudo rm /var/lib/apt/lists/lock will apply to the live OS, not the broken one on your hard disk!

I think the “broken” linux partition must be mounted and your commands would look something like this: sudo rm /media/myroot/var/lib etc.
Anyway, I will try it, got nothing to lose at this point.

Reply
Jaz November 15, 2019 - 4:57 pm

The method that is described in this article is only referring to if you can still reach ubuntu log in. If you use a live cd or usb you would mount the relevant partitions then chroot into that mount point. Then those commands described can be used.

Reply
Jose Tuttu George December 23, 2019 - 4:33 pm

sudo dpkg –configure -a

“Processing was halted because there were too many errors.” is the error I am getting. I regret my decision to upgrade OS. Any help on this? I don’t have live cd. My cd drive broke long time ago.

Reply
sk December 23, 2019 - 4:41 pm

Can’t you switch to tty1 by pressing CTRL+ALT+F1? If yes, you don’t need a live cd. Just run the aforementioned commands one by one and see it solves your problem. If you can’t switch to tty1, may be you should try live usb.

Reply
Kevmate December 29, 2019 - 9:31 pm

This worked brilliantly for me – thanks. One comment, I am using grub and during the update it asked what I wanted to do about grub. I said keep the original. Afterwards grub worked but the menu had changed. Ubuntu now on there twice, and advanced options added. Not sure if I should have upgraded grub. Anyway, all good.

Reply
Kevmate December 29, 2019 - 9:32 pm

BTW – I found that I had to use ctrl-alt-f3 to swicth to tty1.

Reply
tobiz January 13, 2020 - 9:25 pm

This may be just what I’m looking for! My kubuntu 18.04 system failed to boot into kubuntu after having done a synaptic “auto remove” (I thought it was safe!) After that all I could do was boot into a screen that said something like “screen resolution problem” and offered entering tty mode. At that point I tried installing some “kde” things I thought might have got removed but no luck. I therefore resorted to boot from kubuntu 18.04 usb stick into “kubuntu try” and found my main 1Tb disc was still accessible; I did have backups but I made 2 copies of anything else I might need if a full re-install was needed, eg apt-get data. I thought it might be a basic boot problem so tried the boot-repair app, but it seemed to fail and not convinced it improved matters. I’ve just found your procedure and wonder, if, boot-repair hasn’t made things worse, it might work, I understand the point about the main disk being mount, which mine is so under “kubuntu try” could see if it works under chroot. If it does you’ll have saved my life; I’ll let you know.

Reply
vaya March 8, 2020 - 10:29 am

hi, how about if I crash since do sudo apt purge python3. I got tty1, I already do above commands and reboot
but I got same result

Reply
GeneralFault April 9, 2020 - 10:23 pm

This saved me a few hours of work. Thank you very much. My 18.04 LTS system got hosed after I tried to uninstall KDE and some of its applications. The crashing terminal is working again and the battery indicator is back.

Reply
yjojo April 10, 2020 - 12:06 am

You are a hero! Had done an upgrade on AntiX and then could not boot. Followed your steps and I’m back up and running. Thank you!!

Reply
Carlos April 13, 2020 - 10:06 am

Hi, DFD. Which distribution you recommend then?

Reply
Bubba April 26, 2020 - 7:02 am

Is “sudo dpkg –configure -a” supposed to be listed twice?

Reply
sk April 26, 2020 - 11:57 am

Yes, I ran those commands in the same order and it worked.

Reply
Iliyan April 26, 2020 - 12:24 pm

I hope this should work on Linux Mint?

Reply
sk April 26, 2020 - 1:27 pm

Yes, It should work on most Ubuntu derivatives.

Reply
Helpful Herron April 28, 2020 - 5:31 am

If you can’t access the tty or have another problem, check this out: https://ostechnix.com/how-to-boot-into-rescue-mode-or-emergency-mode-in-ubuntu-18-04/

Reply
Tim Palmer April 30, 2020 - 12:54 pm

This article helped me immensely. Thank you very much!

Reply
Tuxor99 April 30, 2020 - 7:18 pm

Fantastic. Worked flawlessly on broken 18.04 directly up to 20.04. Thanks!

Reply
Goutham Vijapur April 30, 2020 - 10:58 pm

I was trying to upgrade my Ubuntu 18.04.4 LTS to 20.04 LTS

I used the ‘update-manager -d’ command as provided in the tutorial (https://ubuntu.com/tutorials/tutorial-upgrading-ubuntu-desktop#1-before-you-start)

At some point of time my screen went blank and was stuck at “[OK] Started Manage, Install and generate color profiles”

After almost 30 mins, I restarted the system and it wouldn’t boot properly. the screen was stuck at “[OK] Started GNOME Display Manager (etc… etc…)”

I followed the solution in this blog and finally I have my system upgraded to Ubuntu 20.04 LTS, up and running with all the files and previously installed softwares intact.

Reply
Yahia Asrawi May 15, 2020 - 6:01 am

Thanks, it helped.

Reply
chola May 16, 2020 - 10:35 pm

Glad you even got to the login screen.
I don’t know what error hit me, OS froze and after I restarted the laptop, Ubuntu won’t get past the EFI loading bit.
It’s ruined my day

Reply
Abishek June 9, 2020 - 11:22 am

When I tried this my login goes in a loop. What went wrong? I am only able to open tty2. Ctrl + Alt + F2

Reply
sk June 9, 2020 - 11:36 am

I don’t know the exact reason. However, you can try to fix the OS from tty2 as well.

Reply
El Cab June 15, 2020 - 9:47 pm

Thank you! I had an older laptop that i tossed out but kept the msata drive and transferred it to virtual box. I followed the above and was able to login in with no problem.

Reply
Scott July 1, 2020 - 7:00 am

In your article titled “How To Fix Broken Ubuntu OS Without Reinstalling It” you stated the first thing I should do is login with live cd and backup my data.
You later stated “At the login screen, press CTRL+ALT+F1 to switch to tty1”.
How do I get to this login screen and login?
When I press the CTRL+ALT+F1 I am asked for a user name and password.
What would the user name and password be?

Reply
sk July 1, 2020 - 11:38 am

At the login screen, press CTRL+ALT+F1 to switch to tty1

It is your actual log in screen where you enter your password to log into your system.

When I press the CTRL+ALT+F1 I am asked for a user name and password.

It is your actual username and its password that you use regularly to log in to your system.

I said backup your data using live cd before following any of these steps. Because, if the steps mentioned in this article didn’t work, you can simply reinstall the system and copy the data from the backup.

Reply
Archie July 1, 2020 - 9:12 pm

what kind of magic is that man.

my mariadb installation went sideways,even after reinstalling, purging and everything, it was still sucking at me.

Ran ur commands blindly, and problem solved. thanks a lot, keep doing the great work dude.

Reply
sk July 1, 2020 - 9:54 pm

Glad it worked out well for you. Cheers, mate!

Reply
Raviprasad Cadambi July 18, 2020 - 7:46 pm

Wow. You are a lifesaver. On a brand new installation i screwed up my Webuzo installation and needed a rebuild. Blindly ran your steps and voila all things back to normal. Thanks a ton!!

Reply
shiva July 26, 2020 - 9:10 pm

sudo apt clean
sudo: apt: command not found

Reply

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. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More