How to cleanup /usr/src folder without a restart/reboot?

Gregorio Montaño 251 Reputation points
2022-08-11T05:43:19.293+00:00

Hi,

Is there a way to clean-up /usr/src in Ubuntu Linux folder without restart/rebooting the VM?

Instructions suggested in Reference does not seem to take effect and I don't want to reboot/restart the VM.

Thanks!

Reference:
https://askubuntu.com/questions/1319112/usr-src-full-with-header-files-purge-and-autoremove-not-helping
https://askubuntu.com/questions/253048/safe-to-remove-usr-src-linux-headers-after-purging-older-linux-images

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,015 questions
{count} votes

Accepted answer
  1. srbhatta-MSFT 8,586 Reputation points Microsoft Employee
    2022-08-11T08:25:58.453+00:00

    Hello @Gregorio Montaño ,
    I guess you are seeing some files like /usr/src/linux-azure-headers-<version-numbers>.
    Those files must belong to a package called something like linux-headers-<version-number>-azure or something similar, you should be able to verify the presence of that package using the below command:

    dpkg -l | grep linux-headers

    and remove with the command:

    dpkg -r <package_name>

    Although I am not very much sure on it's effectiveness without a restart, however please give it a try and let me know.

    If there are other packages depending on the presence of the linux-headers, you should receive a warning or at least a prompt to confirm the action.
    I'd recommend you take a system backup as that package will no longer be available once you remove it, and incase if you need it after being removed, you will atleast have a backup.

    Feel free to respond back and let me know if this helps. :)

    ---------------

    If you find the above information helpful, kindly accept as answer or upvote to increase the relevancy of this post.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.