How to fix Ubuntu not updating issue due to the broken packages

Have you ever faced a broken package error while updating Ubuntu? Do you know that the Apt package manager has a built-in function that can help you solve this situation? Let's show you how.

Ubuntu has proven to be one of the most powerful operating systems, but from time to time, things can go wrong while performing an update process.

Have you ever faced a broken package while updating Ubuntu? Do you know that Apt (which is Ubuntu’s most famous and powerful package manager) has a built-in function that can help you solve this situation and get things back to its normal state?

During this tutorial, we are going to cover how to fix a broken package during your update process. Next, we will discuss some tips and tricks that should help you get out of the broken package situation.

Fix a Broken Package Using APT or APT-GET

As we have mentioned previously, Apt is Ubuntu’s most powerful and useful package manager. Apt has some useful flags that can be used to fix broken packages or packages that are missing some dependencies.

First Method

Step 1. Perform an update using the fix-missing option, and this step will help you to make sure that the required packages are up-to-date.

sudo apt --fix-missing update

Step 2. After the update finishes, you can force Apt to search for any broken packages or missing package dependencies and then correct them. This step will fix and repair the existing packages and install any missing packages.

sudo apt install -f

Second Method Using APT And DPKG

If the previous solution did not work, you could try the next few steps:

Step 1. Try to update your package list using the following command.

sudo apt update

Step 2. Clean up any partially installed package.

sudo apt autoclean

Step 3. Then use the next command to clean the apt cache.

sudo apt clean

Step 4. Next, you can clean up not needed dependencies.

sudo apt autoremove

During running this command, you can quickly identify the broken package. Then you can move on to the next step.

Step 5. If you have identified the package name, then you can use the next command to remove this package forcefully.

sudo dpkg --remove -force --force-remove-reinstreq Package_Name

Fix a Broken Package Using DPKG

During the configuration process and after the installation, you may face some errors. The Apt here is not capable of doing anything. If a package fails during the configuration, the dpkg is the most appropriate tool that will take care of this situation and will fix it.

Step 1. First force the dpkg tool to reconfigure any currently broken configured package.

sudo dpkg --configure -a

If this step did not fix the problem, move on to the next step.

Step 2. List all the packages that have been marked as required to be installed by dpkg.

sudo dpkg -l | grep ^..r

After executing the previous command, you should see packages with problems.

Step 3. Now you can use the following command to remove the broken packages forcibly.

sudo dpkg --remove --force-remove--reinstreq

Step 4. After the previous command finishes successfully, then you need to clean everything using the Apt.

sudo apt clean

Step 5. Next, you can get back to your update process.

sudo apt update

Finally, in this tutorial, we have covered different methods to fix your broken or misconfigured package. Now you can move on and start using your system normally again.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.


Please enter your comment!
Please enter your name here




How to create a bootable CentOS Live USB drive on Windows

create centOS Live USB drive
CentOS ISO downloads are available in two different variations - Minimal ISO and DVD ISO. So what are these? In this guide, you will know how to create a CentOS Live USB drive that can also be used to install CentOS.
Uninstall Programs in Ubuntu
Uninstallation of programs can be done by graphical way using the Ubuntu Software Center, and the Synaptic Package manager. Command-line way of doing it is also possible using apt-get and aptitude commands. We shall discuss each one of them in detail.
multiboot distros usb
A bootable Linux USB drive, which also referred to as a Live USB drive, is a drive containing files that enable a computer to boot into a specific Linux distro. It is most commonly used to test-drive various Linux distros before installing on the computer for use as a daily driver.