Score:6

I accidentally deleted the directory /lib/modules/5.11.0-22-generic. How can I recover it?

cn flag

I am on Ubuntu 21.04 (Hirsute Hippo) and I accidentally deleted the 5.11.0-22-generic directory in directory /lib/modules.

How can I recover or reinstall it?

Artur Meinild avatar
vn flag
Did you try `sudo apt install linux-image-generic` ?
vanadium avatar
cn flag
@ArturMeinild that will not help.That package is installed, and `apt install` will just report that.
Artur Meinild avatar
vn flag
My bad, I actually also meant to issue a reinstall.
ag flag
This is exactly why it requires root rights to remove those files... Are you sure this is the only thing that is needing fixing?
Zanna avatar
kr flag
@PeterMortensen more importantly, I guess, it contains directories with all the drivers built for that kernel... But there is a conflict between the title of the question and the body - `linux-image-generic` is a meta package and so it provides no files - it only exists for package management reasons. I am going to edit the title and make it match the body, since the answer is about that.
Score:22
cn flag

Keep out of your system files in the first place. It is hard to understand how one can "accidentally" delete that directory. Forgive this rant, but it has to get out of my way.

Presumably, 5.11.0-22 is not the kernel you are currently running. Otherwise, you would not be able to restart.

You can reinstall that kernel image with the command

sudo apt install --reinstall linux-headers-5.11.0-22-generic linux-modules-5.11.0-22-generic linux-modules-extra-5.11.0-22-generic

The --reinstall option should indicate apt to effectively redownload and reinstall the package. That should bring back in any missing files.

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.