You have tried to remove a package in Ubuntu but to no avail ? In this short tutorial, we shall 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 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.
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) )
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
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.