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?

  • 1
    Did you try sudo apt install linux-image-generic ? – Artur Meinild Jul 21 at 9:49
  • 1
    @ArturMeinild that will not help.That package is installed, and apt install will just report that. – vanadium Jul 21 at 10:17
  • 2
    My bad, I actually also meant to issue a reinstall. – Artur Meinild Jul 21 at 10:31
  • This is exactly why it requires root rights to remove those files... Are you sure this is the only thing that is needing fixing? – Thorbjørn Ravn Andersen Jul 21 at 21:01
  • What do you mean by "linux-image-generic" in "deleted linux-image-generic" (the title)? (Directory /lib/modules/5.11.0-22-generic contains files modules.dep, modules.dep.bin, modules.alias, modules.softdep, modules.alias.bin, modules.symbols, modules.symbols.bin, modules.builtin.bin, modules.builtin.alias.bin, and modules.devname.) – Peter Mortensen Jul 22 at 7:34

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.