How to remove broken packages in Ubuntu

You have tried to remove a package in Ubuntu but to no avail ? In this short tutorial, we will provide some tips using Ubuntu built-in utilities that may help remove a potentially broken package on your Debian OS. Let’s get started.

Lock issue ?

Lock files sometimes prevent a package update or installation. This may have occurred during a previous package installation for instance. Since sometimes the lock files will remain in the memory, you would have to delete them manually using the commands:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

For more on this, refer to our article on lock related issues here.

Using DPKG 

You may have tried to execute a dpkg purge, but this results in an error :

dpkg: error processing package [pckge_name] (–purge))

but still no success ?

If you do not know which packages are broken, you could first try to force the dpkg tool to reconfigure these ill-configured packages. Run the command below:

sudo dpkg –configure -a               [dpkg configure command]

This will display the broken packages . Now you would have to remove the broken packages using the command  :

sudo dpkg –remove –force-remove –reinstreq     [dpkg remove package command]

If you know the package name, .e.g. pckge_name, proceed as follows:

sudo mv /var/lib/dpkg/info/pckge_name.* /tmp/
sudo dpkg –remove –force-remove-reinstreq pckge_name

The dpkg force package removal may yield the error :

dpkg: error processing archive [pckge_name] (–install) )

Read: How to install and uninstall applications in Ubuntu

Using APT

Using APT, you will also be able to fix some broken packages or missing dependencies. This may have happened during a package install or update for instance. Try the following commands:

To make sure there are no newer versions of the packages, invoke the
command :

sudo apt –fix-missing update         [fix broken packages Ubuntu]

According to our article on how to fix unmet dependencies, the command below will try to fix current installations and will attempt to install missing packages :

sudo apt install -f

If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.


amin nahdy

Amin Nahdy, an aspiring software engineer and a computer geek by nature as well as an avid Ubuntu and open source user. He is interested in information technology especially Linux based ecosystem as well as Windows and MacOS. He loves to share and disseminate knowledge to others in a transparent and responsible way.

This Post Has 5 Comments

  1. Vladimir

    sudo apt update –fix-missing

  2. John W.

    sudo dpkg –configure -a produces an error message, namely: “action option needed”

    1. net2

      Please check out the man page of dpkg : dpkg
      As well as the following question:
      dpkg –configure
      In case you have issues, please use –reconfigure option

  3. Mladen Gogala

    The “fix missing” thing doesn’t work:

    root@umajor:/home/mgogala# apt update –fix-missing
    E: The update command takes no arguments

    1. net2

      Could you try to perform the following two commands:
      sudo apt-get autoremove
      sudo apt –fix-missing update

Leave a Reply