Delete old Ubuntu kernel

Source: Internet
Author: User

Ubuntu's kernel is often upgraded, and the old kernel does not automatically unload. Long time, there is a lot of kernel garbage, we need to manually clean up.

    • First use Uname-a to view the current kernel version:
uname -alinux xzc3.13. 0--generic #2of all: £x86_64 x86_64 x86_64 Gnu/linux

Visible current version is 3.13.0-46

    • Look at the kernel version of the current system installation with Dpkg--get-selections|grep Linux:
[Email protected]:~$ dpkg--get-selections|grepLinuxlibselinux1:amd64InstallLinux-firmwareInstallLinux-genericInstallLinux-headers-3.13.0- $                InstallLinux-headers-3.13.0- $-genericInstallLinux-headers-genericInstallLinux-image-3.13.0- $-genericInstallLinux-image-extra-3.13.0- --Generic Deinstalllinux-image-extra-3.13.0- $-genericInstallLinux-image-genericInstallLinux-libc-dev:amd64InstallLinux-signed-genericInstallLinux-signed-image-3.13.0- --Generic Deinstalllinux-signed-image-3.13.0- $-genericInstallLinux-signed-image-genericInstallLinux-sound-baseInstallPPTP-linuxInstallSyslinuxInstallSyslinux-commonInstallSyslinux-legacyInstallutil-linuxInstall

Where Linux-headers, linux-image, and linux-signed begin with kernel-related. With a version number, such as linux-image-extra-3.13. 0-44-generic) is deleted. Be careful not to delete the version you are currently using. The following install indicates that the installation has been installed, and the deinstall indicates that it has been installed and is now deleted (no space is occupied).

    • sudo apt-get purge to remove

sudo apt-get purge linux-image-extra-3.13. 0-44-generic

< Span style= "color: #800080;" >sudo Apt-get purge Linux-signed-image-3.13. 0-44-generic

sudo Apt-get purge linux-headers-3.13. 0-44 (This seems to automatically put linux-headers-3.13.46-generic Delete, if not deleted, < Span style= "color: #800080;" >sudo Apt-get Purge linux-headers-3.13. 0-46-generic )

Be careful not to use the sudo apt-get remove to remove, linux-signed-image-3.13 will appear. 0-44-generic deinstall. Of course, it is also possible to delete the purge when running again.

    • Update the boot menu with sudo update-grub

A netizen uses regular expression to write a script, did not try the script effect how:

' linux-* ' sed ' /^ii/!d;/ ' "  "s/\ (. *\)-\ ([^0-9]\+\)/\1/")"'  /d;s/^[^]* [^]* \ ([^]*\). */\1/;/[0-9]/!d'xargssudo apt-get-y Purge

Delete old Ubuntu kernel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.