How To Fix Broken Ubuntu OS Without Reinstalling It

Over the course of time, your system can be plagued with errors that can render it broken or unusable. A classic example is the inability to install software packages, update or upgrade the system. Other times, you may encounter a black screen during login preventing you from accessing your system.

An extreme fix would be to reinstall your Ubuntu OS right away, but this means that you’ll lose all your precious files and applications. Instead of taking that path, a few fixes can come in handy with a Live CD or USB bootable medium.

Let’s check out a few solutions that can help you fix broken Ubuntu OS without reinstalling it.

Fix the inability to install software packages, update or upgrade the system

Sometimes you could run into the error ‘Could not get lock /var/lib/dpkg/lock.’ This also mirrors the error ‘Could not get lock /var/lib/apt/lists/lock‘ error.

Could not get lock /var/lib/dpkg/lock error
Could not get lock /var/lib/dpkg/lock error

This is usually caused by an interrupted update or upgrades process such as when the power goes out or when you press CTRL + C to interrupt the process. This error prevents you from installing any packages or even update or upgrade your system.

To resolve this error, remove the lock file(s) as shown.

$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/lib/dpkg/lock-frontend

In case you bump into the error about the apt-cache lock such as /var/cache/apt/archives/lock, remove the lock file as shown.

$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/cache/apt/archives/lock

Next, reconfigure dpkg and clear the local repository of any remnants left in the /var/cache file

$ sudo dpkg --configure -a
$ sudo apt clean
Fix Ubuntu when it freezes in boot time due to Graphic drivers

NVIDIA drivers are notorious for causing crashes on Ubuntu systems. Sometimes, your system can boot and get stuck at the purple screen as shown.

Stuck at Ubuntu Booting
Stuck at Ubuntu Booting

Other times, you might get a black screen. When this happens, the only option is to boot into rescue mode or emergency mode on Ubuntu.

Let’s check out how to solve this issue. First, reboot your machine and press ‘e’ on the first option.

Ubuntu Boot Grub Menu
Ubuntu Boot Grub Menu

This brings you to the editing mode as shown. Scroll until to get to the line starting with ‘Linux’. Append the string nomodeset as shown.

Edit Ubuntu Boot Parameters
Edit Ubuntu Boot Parameters

Lastly, press CTRL + X or F10 to exit and continue booting. If you still cannot boot into your system, try adding the parameter nouveau.noaccel=1.

Now, this is a temporary fix and won’t apply the next time you log in. To make the changes permanent, you need to edit the /etc/default/grub file.

$ sudo nano /etc/default/grub

Scroll and locate the line that reads:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Set it to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

Save the changes and exit.

Lastly, you need to update grub as follows:

$ sudo update-grub

Once you are done, reboot your system. This should fix the problem.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

9 thoughts on “How To Fix Broken Ubuntu OS Without Reinstalling It”

  1. An extreme fix would be to reinstall your Ubuntu OS right away, but this means that you’ll lose all your precious files and applications.”

    That only happens when your original install was a lazy acceptance of defaults by pressing “NEXT”, “NEXT’, “NEXT”. If you set up a separate /home partition then you can re-install the distro without a worry about “precious files”.

    An even better solution to setting up just /home, would be to also set up a separate /data partition for all Documents, Videos, Pictures, and other data. And, of course, backup, backup, and then back up some more to be able to restore any “precious files” at any time.

    BTW – a separate /data partition allows for easily changing distros one uses, and using the same data across more than one distro (multi-booting).

    Reply
    • YES! I don’t understand why people install on a single partition. Having a separate /home partition is so much better for system upgrades.

      Reply
      • Recently I have been using Solus Plasma. It’s been a very reliable and solid Distro. However, it has just begun not completing the boot process. Log in and it goes to a blank dark screen with a blank screen with a cursor blinking? If a user can’t even get into the system. How can anything be fixed? BTW – even the Solux “advanced options” log in did the same behavior.

        Reply
    • I totally agree and am glad to have come across this. I fixed this a few days ago with an online instruction I found, having /home on a separate data carrier.

      Coming from the ‘electronic side of business life‘ with many years of MS Windows, and custom builds PCs for our family, I consider myself knowledgeable [in the DOS/Windows] computer world.

      When MS screwed up multiple updates last March, that broke the camel’s back. I kicked Win10 off my PC and installed Linux. First Ubuntu, then Linux Mint (both LTS).

      Since then, I bemoaned, not having the system and data separated. My PC’s always had physically separated C:/ and D:/ drives.

      You guys seem all to be seasoned, and therefore easily forget that these kinds of ‘hacks‘ are not known to those who came recently to Linux.

      Maybe one of you should start writing a book with Linux Desktop hacks and tips. It would benefit both Linux beginners and advanced users. I have to scramble the bits and pieces together from the Internet, spending a huge amount of time, looking for answers to a specific issue or problem I can’t solve with my [yet] limited knowledge on my own. :)

      Just my two cents worth. Glad to be here and get the tips I really need.

      Hans

      Reply
      • There are quite a few Linux hacks books out there. Many of them are free to download. Check out sites such as DistroWatch, ItsFoss, FossLinux, HowToGeek, MakeUseOf, Make TechEasier, and others. Over the years I have built up a library of links to Linux articles on those sites. AND don’t forget TecMint. Go through their archive of articles. I’m sure you will find many that will give you what you are looking for.

        One book I can think of is “101 Linux Hacks”. Also, do an Internet search on “Linux hacks” and similar terms.

        Reply
        • Thanks for your reply and the recommendation, dragonmouth. I knew a few of these links already but not all of them. I certainly will search for ‘101 Linux Hacks´. Sounds like many tips in one place.
          Stay safe, Hans :)

          Reply
      • “I like this idea. What would you put in /data vs /home?” /DATA partition usually contains Documents, Videos, Pictures/Images, Music folders. IOW, any files that you create. It could contain your Downloads.

        For a more in-depth discussion, do a search on “Separate home partition” and “Separate data partition”. The articles found will tell you why you should/should not set up separate partitions. Exactly how to set up these partitions in Windows and in Linux. What files to put in these partitions. While you’re at it, check out articles on the pros and cons of setting up various other Linux partitions (/tmp, /var, /opt, /usr).

        Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

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