Site icon DesignLinux

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

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

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

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

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.

Exit mobile version