Our goal is to keep your server, secured and updated in order to minimize the possibility for malicious users to compromise your server.
While this is a good practice, people, tend to forget, that cleaning old and unused software on your server is also important, not only for disk space savings but also for security reasons.
Here we are going to show you, how you can remove old unused Linux Kernels and maintain your server on top shape, in order to do so, you need to connect to your box using Putty or any other SSH client software (or just ssh connect from your Linux terminal).
First let's make sure you have the latest kernel installed (and loaded).
yum update kernel
If no update is needed then check if the latest kernel is loaded and if not restart your server.
Linux server.gozenhosting.net 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
The above command shows the loaded Kernel on your system, in order to be sure you have the latest installed, loaded check how many Kernels you have on your server and compare versions.
rpm -q kernel
Now let's remove the old ones except the one loaded.
package-cleanup --oldkernels --count=1