Last active
February 23, 2025 15:10
-
-
Save ckng/5a533fcb7334fb60cbad3a17708fcac4 to your computer and use it in GitHub Desktop.
Ubuntu - Purge old kernels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uname -a | |
dpkg --list | egrep -i --color 'linux-image|linux-headers|linux-modules' | awk '{ print $2 }' > kernels.txt | |
grep -v $(uname -r) kernels.txt > kernels_to_delete.txt | |
# Verify current kernal version is not in the list | |
grep $(uname -r) kernels_to_delete.txt | |
cat kernels_to_delete.txt | xargs sudo apt purge -y | |
sudo apt autoremove |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment