Cyberithub

How to Fix Broken Packages in Debian 10/11{Easy Methods}

Advertisements

In this article, I will take you through the steps to fix broken packages in Debian 10/11. Sometimes you might have noticed that whenever you try to run any update or try to install a new package then you always encountering broken package error. While this error could occur due to various number of reasons depending on server to server but here we will cover all the possible solutions that can help you solve this error with the current set of utilities you will have in your Debian based systems. So without any further delay, Let's dive in !!

How to Fix Broken Packages in Debian 10/11{Easy Methods}

How to Fix Broken Packages in Debian 10/11

Also Read: How to Install curl on Debian 10/11 in 6 Easy Steps

In a typical Debian System, you will always find package managers like apt, apt-get and dpkg. So it is important that we try to use these tools only to solve our error. It is because even if you want to use any other utility to find and fix the broken package issue then you cannot do it as this error stops you to install any new package.

Method 1: Using apt or apt-get command

In this method first you can use apt utility to install any missing update using apt --fix-missing update command and ensure that there are no further update remains to be installed.

root@debian:~# apt --fix-missing update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main Sources [38.9 kB]
Get:5 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [48.0 kB]
Fetched 170 kB in 2s (90.5 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

Now you can simply run apt update command to see if it works.

root@debian:~# apt update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://deb.debian.org/debian bullseye-updates InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

If it does not work then you can attempt fixing all broken packages by using apt install -f command as shown below.

root@debian:~# apt install -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libjq1 libonig5
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

As you can see from above output, there are few packages installed which are no longer required in the System. So to remove those packages you need to run apt autoremove -y command as shown below.

root@debian:~# apt autoremove -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
libjq1 libonig5
0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
After this operation, 1,035 kB disk space will be freed.
(Reading database ... 141510 files and directories currently installed.)
Removing libjq1:amd64 (1.6-2.1) ...
Removing libonig5:amd64 (6.9.6-1.1) ...
Processing triggers for libc-bin (2.31-13) ...

If you find any packages that needs to be upgraded then you can upgrade it by using apt upgrade -y command as shown below.

root@debian:~# apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-image-5.10.0-9-amd64
The following packages will be upgraded:
base-files gir1.2-mutter-7 gnome-maps gnome-shell gnome-shell-common gnome-shell-extension-prefs krb5-locales libapr1 libatk-wrapper-java
libatk-wrapper-java-jni libbluray2 libc-bin libc-dev-bin libc-devtools libc-l10n libc6 libc6-dev libflatpak0 libgssapi-krb5-2 libk5crypto3 libkrb5-3
libkrb5support0 libmutter-7-0 libnautilus-extension1a libpam-modules libpam-modules-bin libpam-runtime libpam0g libperl5.32 libspeechd2 linux-image-amd64
linux-libc-dev locales mutter-common nautilus nautilus-data perl perl-base perl-modules-5.32 python3-reportbug python3-speechd reportbug
speech-dispatcher speech-dispatcher-audio-plugins speech-dispatcher-espeak-ng
45 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

If you are still facing the same error then you can try doing some cleanups using below mentioned commands.

root@debian:~# rm -rf /var/lib/apt/lists/*
root@debian:~# rm /var/cache/apt/*.bin
root@debian:~# apt clean

 

Method 2: Using dpkg command

Another method that you can use is through dpkg command. In this method first you need reconfigure all the partially installed packages by using dpkg --configure -a command as shown in the below output.

root@debian:~# dpkg --configure -a

If the above command does not solve your problem then in the next step first you need to find all the broken packages using dpkg -l | grep ^..r command as shown below.

root@debian:~# dpkg -l | grep ^..r

If you see any broken packages then you can remove it by using dpkg --force-all --remove package-name command.

root@debian:~# dpkg --force-all --remove package-name

You can also remove all the files from /var/lib/dpkg/updates directory using rm -rf /var/lib/dpkg/updates/* command as shown below. More about dpkg command.

root@debian:~# rm -rf /var/lib/dpkg/updates/*

You can also use both apt and dpkg command together to fix broken package issues. Hopefully all the above shown steps are enough to solve your error.

1 thought on “How to Fix Broken Packages in Debian 10/11{Easy Methods}”

Leave a Comment