cannot use `sudo apt install` any packages - sudo apt --fix broken install error
I cannot use sudo apt install
any packages
I have tried sudo apt --fix broken install
however it keep hitting dependencies error.
$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
linux-image-5.11.0-41-generic
Suggested packages:
fdutils linux-doc | linux-hwe-5.11-source-5.11.0 linux-hwe-5.11-tools
The following NEW packages will be installed:
linux-image-5.11.0-41-generic
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
7 not fully installed or removed.
Need to get 0 B/11.5 MB of archives.
After this operation, 11.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 259233 files and directories currently installed.)
Preparing to unpack .../linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb ...
Unpacking linux-image-5.11.0-41-generic (5.11.0-41.45~20.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb (--unpack):
unable to open '/boot/vmlinuz-5.11.0-41-generic.dpkg-new': Operation not permitted
Errors were encountered while processing:
/var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Solution 1:
You can easily fix this issue!
You need to force overwrite the files, probably the last time you ran apt upgrade
, a kernel upgrade was there. It seems like you are probably using an antivirus, if yes then diable it and proceed, and if no then proceed
So after making sure your antivirus services are disabled run -
sudo dpkg -i --force-overwrite /var/cache/apt/archives/linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb
Now the problem should be gone 😃
Meaning of what we did
Normally, some antivirus services doesn't let tools like Dpkg to acess /boot
directory in order to provide security but when there is a kernel upgrade Dpkg is forced to access the /boot
directory, without it, it cannot install kernel, the antivirus wasn't allowing Dpkg to use /boot
so disabling antivirus will allow Dpkg to use /boot
After that, we ran a command, that command does nothing but allow Dpkg to forceoverwrite the directory in which the package (kernel) linux-image-5.11.0-41-generic_5.11.0-41.45~20.04.1_amd64.deb
was installed, So that Dpkg can reinstall it.
Confirming everything
First of all run sudo apt --fix-broken install
to confirm the fix.
Then make sure the kernel is installed by sudo apt-get upgrade
Now after this is done you may want to clean the computer by running sudo apt clean && sudo apt autoremove
I hope so, I helped
Solution 2:
The blocking is due to antivirus program. Removed them:
sudo dpkg --purge mfedx
sudo dpkg --purge mcafeetp
sudo dpkg --purge mcafeeespaac
sudo dpkg --purge mcafeeespfileaccess
Sudo dpkg --purge mcafeeesp
sudo dpkg --purge mcafeert
sudo dpkg --purge mfecma
sudo dpkg --purge mfert