This brief guide explains how to fix "Package operation failed" error in Ubuntu Linux and its derivatives such as Linux Mint, Pop OS and Elementary OS etc.
The other day I was trying to update the Oracle VirtualBox to its latest version on Ubuntu desktop. But the update didn't go well and I end up with following error.
Package operation failed The installation or removal of a software package failed.
It wasn't the first time I got this kind of error. I have had this error so many times, and I have fixed it too by searching on the Ubuntu forums and Google. But this time I forgot how I solved it in the past. So, I decided to document the procedure, so that someone can use this procedure if they have the same issue.
Well, let me show you how I did it.
I ran the following commands one by one in Terminal:
$ sudo apt-get update
$ sudo apt-get clean
$ sudo apt-get autoremove
$ sudo apt-get update && sudo apt-get upgrade
$ sudo dpkg --configure -a
$ sudo apt-get install -f
When I executed the last command, I got the following error.
[...] E: Sub-process /usr/bin/dpkg returned an error code (1)
Oops! Another error??
However, I opened the Software Updater from the Menu. This time it displayed a message: The update has already been already downloaded.
Cool then. I just hit the Install now button. The installation went good and completed without any issues.
Hope this helps.