Score:0

How to remove `linux-image-5.11.0-41-generic` manually in ubuntu 20.04?

cn flag

How to remove linux-image-5.11.0-41-generic manually in ubuntu 20.04?

I am getting errors like this when I try to update, install, remove package.

(Reading database ... 211704 files and directories currently installed.)
Removing linux-image-5.11.0-41-generic (5.11.0-41.45~20.04.1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.11.0-41-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.11.0-41-generic (--remove):
 installed linux-image-5.11.0-41-generic package post-removal script subpr
ocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.11.0-41-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

How to fix it.

I tried every possibility mentioned below:

autoremove, purge, remove, dpkg, fix broken etc. How to remove it manually?

Note: My computer is working fine without any problem and booting normal. I can use my laptop but the main problem is that I can't install, remove or fix any packages.

Artur Meinild avatar
vn flag
Did you read the error message? It says there are errors in `/etc/default/grub`, thus it's a duplicate to this question: [cannot remove linux image with sudo apt autoremove](https://askubuntu.com/questions/1386529/cannot-remove-linux-image-with-sudo-apt-autoremove)
cn flag
@ArturMeinild Finally I solved this problem in another way. I find all file name containing `linux-image-5.11.0-41-generic` and deleted it.
cn flag
@ArturMeinild I deleted all file containing `linux-image-5.11.0-41-generic` on `/var/lib/dpkg/info` Is everything fine Or I did wrong? please reply!
nobody avatar
gh flag
Fix your `/etc/default/grub` follow @ArturMeinild link for that.
Someone avatar
my flag
@Kheersagarpatel It's generally a bad practice to manually remove files from `/var/lib/dpkg/info`. It's fine for now, but in future it will definitely destroy your system.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.