Remove all kernel packages except the currently used one
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
How can I automatically delete all other kernels which I'm not using?
So, here's my situation:
- Using different versions of Ubuntu / CentOS
- Automatic updates were on -> Linux downloaded many new kernel versions
- Now I want to delete all other kernel versions, except the one I'm currently using
Code:
#find out current kernel version:
uname -r
#check which versions are downloaded to computer
dpkg --get-selections | grep linux-image
#delete desired kernel
sudo apt-get purge [KERNEL]
#autoremove
sudo apt-get autoremove
There can be easily more than 15 kernels in one linux, and I have more than 50 linuxes which I have to go through.
ubuntu apt linux-kernel package-management
add a comment |
up vote
3
down vote
favorite
How can I automatically delete all other kernels which I'm not using?
So, here's my situation:
- Using different versions of Ubuntu / CentOS
- Automatic updates were on -> Linux downloaded many new kernel versions
- Now I want to delete all other kernel versions, except the one I'm currently using
Code:
#find out current kernel version:
uname -r
#check which versions are downloaded to computer
dpkg --get-selections | grep linux-image
#delete desired kernel
sudo apt-get purge [KERNEL]
#autoremove
sudo apt-get autoremove
There can be easily more than 15 kernels in one linux, and I have more than 50 linuxes which I have to go through.
ubuntu apt linux-kernel package-management
Check the second answer on this post: askubuntu.com/questions/2793/… I think that is what you are looking for.
– blametheadmin
Feb 3 '17 at 8:26
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
How can I automatically delete all other kernels which I'm not using?
So, here's my situation:
- Using different versions of Ubuntu / CentOS
- Automatic updates were on -> Linux downloaded many new kernel versions
- Now I want to delete all other kernel versions, except the one I'm currently using
Code:
#find out current kernel version:
uname -r
#check which versions are downloaded to computer
dpkg --get-selections | grep linux-image
#delete desired kernel
sudo apt-get purge [KERNEL]
#autoremove
sudo apt-get autoremove
There can be easily more than 15 kernels in one linux, and I have more than 50 linuxes which I have to go through.
ubuntu apt linux-kernel package-management
How can I automatically delete all other kernels which I'm not using?
So, here's my situation:
- Using different versions of Ubuntu / CentOS
- Automatic updates were on -> Linux downloaded many new kernel versions
- Now I want to delete all other kernel versions, except the one I'm currently using
Code:
#find out current kernel version:
uname -r
#check which versions are downloaded to computer
dpkg --get-selections | grep linux-image
#delete desired kernel
sudo apt-get purge [KERNEL]
#autoremove
sudo apt-get autoremove
There can be easily more than 15 kernels in one linux, and I have more than 50 linuxes which I have to go through.
ubuntu apt linux-kernel package-management
ubuntu apt linux-kernel package-management
edited Feb 3 '17 at 21:59
Gilles
523k12610461576
523k12610461576
asked Feb 3 '17 at 8:01
NoobPenguin
163
163
Check the second answer on this post: askubuntu.com/questions/2793/… I think that is what you are looking for.
– blametheadmin
Feb 3 '17 at 8:26
add a comment |
Check the second answer on this post: askubuntu.com/questions/2793/… I think that is what you are looking for.
– blametheadmin
Feb 3 '17 at 8:26
Check the second answer on this post: askubuntu.com/questions/2793/… I think that is what you are looking for.
– blametheadmin
Feb 3 '17 at 8:26
Check the second answer on this post: askubuntu.com/questions/2793/… I think that is what you are looking for.
– blametheadmin
Feb 3 '17 at 8:26
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
On Ubuntu you can use purge-old-kernels
to purge old kernels , to install it:
For ubuntu 16.04
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F430BBA5
sudo add-apt-repository ppa:byobu/ppa
sudo apt-get update
sudo apt-get install byobu
Also you can install it without adding the ppa
: sudo apt-get install byobu
For Ubuntu versions lower than 16.04
sudo add-apt-repository ppa:bikeshed/ppa
sudo apt-get update
sudo apt-get install bikeshed
Run the following command to keeping the latest 2 kernel :
sudo purge-old-kernels
You can specify the number n
of kernel to keep:
sudo purge-old-kernels --keep n
n=1
:
sudo purge-old-kernels --keep 1
On centOS install yum-utils
package :
yum install yum-utils
To keep the latest n
kernels , run:
package-cleanup --oldkernels --count=n
n=1
:
package-cleanup --oldkernels --count=1
add a comment |
up vote
0
down vote
Be aware, this command removes all kernel images and headers of major release 4, but not the running one.
apt purge $(dpkg-query -W -f='$binary:Packagen' 'linux-image-4*' 'linux-headers-4*' | grep -v $(uname -r))
add a comment |
up vote
0
down vote
You can try the below command. Before you execute apt-get purge, just double check the output of your grep to not contain your current kernel version
dpkg --list | grep linux-image | awk 'print $2' | grep -v linux-image-`uname -r` | xargs apt-get purge
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
On Ubuntu you can use purge-old-kernels
to purge old kernels , to install it:
For ubuntu 16.04
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F430BBA5
sudo add-apt-repository ppa:byobu/ppa
sudo apt-get update
sudo apt-get install byobu
Also you can install it without adding the ppa
: sudo apt-get install byobu
For Ubuntu versions lower than 16.04
sudo add-apt-repository ppa:bikeshed/ppa
sudo apt-get update
sudo apt-get install bikeshed
Run the following command to keeping the latest 2 kernel :
sudo purge-old-kernels
You can specify the number n
of kernel to keep:
sudo purge-old-kernels --keep n
n=1
:
sudo purge-old-kernels --keep 1
On centOS install yum-utils
package :
yum install yum-utils
To keep the latest n
kernels , run:
package-cleanup --oldkernels --count=n
n=1
:
package-cleanup --oldkernels --count=1
add a comment |
up vote
2
down vote
On Ubuntu you can use purge-old-kernels
to purge old kernels , to install it:
For ubuntu 16.04
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F430BBA5
sudo add-apt-repository ppa:byobu/ppa
sudo apt-get update
sudo apt-get install byobu
Also you can install it without adding the ppa
: sudo apt-get install byobu
For Ubuntu versions lower than 16.04
sudo add-apt-repository ppa:bikeshed/ppa
sudo apt-get update
sudo apt-get install bikeshed
Run the following command to keeping the latest 2 kernel :
sudo purge-old-kernels
You can specify the number n
of kernel to keep:
sudo purge-old-kernels --keep n
n=1
:
sudo purge-old-kernels --keep 1
On centOS install yum-utils
package :
yum install yum-utils
To keep the latest n
kernels , run:
package-cleanup --oldkernels --count=n
n=1
:
package-cleanup --oldkernels --count=1
add a comment |
up vote
2
down vote
up vote
2
down vote
On Ubuntu you can use purge-old-kernels
to purge old kernels , to install it:
For ubuntu 16.04
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F430BBA5
sudo add-apt-repository ppa:byobu/ppa
sudo apt-get update
sudo apt-get install byobu
Also you can install it without adding the ppa
: sudo apt-get install byobu
For Ubuntu versions lower than 16.04
sudo add-apt-repository ppa:bikeshed/ppa
sudo apt-get update
sudo apt-get install bikeshed
Run the following command to keeping the latest 2 kernel :
sudo purge-old-kernels
You can specify the number n
of kernel to keep:
sudo purge-old-kernels --keep n
n=1
:
sudo purge-old-kernels --keep 1
On centOS install yum-utils
package :
yum install yum-utils
To keep the latest n
kernels , run:
package-cleanup --oldkernels --count=n
n=1
:
package-cleanup --oldkernels --count=1
On Ubuntu you can use purge-old-kernels
to purge old kernels , to install it:
For ubuntu 16.04
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F430BBA5
sudo add-apt-repository ppa:byobu/ppa
sudo apt-get update
sudo apt-get install byobu
Also you can install it without adding the ppa
: sudo apt-get install byobu
For Ubuntu versions lower than 16.04
sudo add-apt-repository ppa:bikeshed/ppa
sudo apt-get update
sudo apt-get install bikeshed
Run the following command to keeping the latest 2 kernel :
sudo purge-old-kernels
You can specify the number n
of kernel to keep:
sudo purge-old-kernels --keep n
n=1
:
sudo purge-old-kernels --keep 1
On centOS install yum-utils
package :
yum install yum-utils
To keep the latest n
kernels , run:
package-cleanup --oldkernels --count=n
n=1
:
package-cleanup --oldkernels --count=1
answered Feb 4 '17 at 20:08
GAD3R
24.6k1749104
24.6k1749104
add a comment |
add a comment |
up vote
0
down vote
Be aware, this command removes all kernel images and headers of major release 4, but not the running one.
apt purge $(dpkg-query -W -f='$binary:Packagen' 'linux-image-4*' 'linux-headers-4*' | grep -v $(uname -r))
add a comment |
up vote
0
down vote
Be aware, this command removes all kernel images and headers of major release 4, but not the running one.
apt purge $(dpkg-query -W -f='$binary:Packagen' 'linux-image-4*' 'linux-headers-4*' | grep -v $(uname -r))
add a comment |
up vote
0
down vote
up vote
0
down vote
Be aware, this command removes all kernel images and headers of major release 4, but not the running one.
apt purge $(dpkg-query -W -f='$binary:Packagen' 'linux-image-4*' 'linux-headers-4*' | grep -v $(uname -r))
Be aware, this command removes all kernel images and headers of major release 4, but not the running one.
apt purge $(dpkg-query -W -f='$binary:Packagen' 'linux-image-4*' 'linux-headers-4*' | grep -v $(uname -r))
answered Feb 4 '17 at 10:28
ingopingo
61944
61944
add a comment |
add a comment |
up vote
0
down vote
You can try the below command. Before you execute apt-get purge, just double check the output of your grep to not contain your current kernel version
dpkg --list | grep linux-image | awk 'print $2' | grep -v linux-image-`uname -r` | xargs apt-get purge
add a comment |
up vote
0
down vote
You can try the below command. Before you execute apt-get purge, just double check the output of your grep to not contain your current kernel version
dpkg --list | grep linux-image | awk 'print $2' | grep -v linux-image-`uname -r` | xargs apt-get purge
add a comment |
up vote
0
down vote
up vote
0
down vote
You can try the below command. Before you execute apt-get purge, just double check the output of your grep to not contain your current kernel version
dpkg --list | grep linux-image | awk 'print $2' | grep -v linux-image-`uname -r` | xargs apt-get purge
You can try the below command. Before you execute apt-get purge, just double check the output of your grep to not contain your current kernel version
dpkg --list | grep linux-image | awk 'print $2' | grep -v linux-image-`uname -r` | xargs apt-get purge
answered Nov 26 at 20:15
skashyap
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f342199%2fremove-all-kernel-packages-except-the-currently-used-one%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Check the second answer on this post: askubuntu.com/questions/2793/… I think that is what you are looking for.
– blametheadmin
Feb 3 '17 at 8:26