Linux kernel could be treated as the core of a Linux operating system like Ubuntu, Debian etc. Therefore there may be instances where you need to upgrade the kernel to the latest version. In this tutorial, I’ll show you how to upgrade Linux kernel of your VPS server to latest mainline kernel build, the 4.11.2 kernel version. For example, I am using Ubuntu 16.04 VPS.
Note: If the virtualization type of the VPS provided by your VPS provider is OpenVZ, then unfortunately you won’t be able to upgrade your Linux kernel since OpenVZ sticks at 2.6 kernel.
This tutorial assumes that you have basic Linux knowledge on handling Linux shell and most importantly you have your own VPS server with root access. If necessary, you can follow my tutorial on “First Connection to your VPS“.
So Let’s start to Upgrade your Kernel
Log in to your server as root using your favorite SSH client.
Step 1: Update Ubuntu repository and upgrade all packages
sudo apt-get update
sudo apt-get upgrade -y
Then reboot your server.
sudo reboot
After rebooted, issue following command to check whether there are no pending updates.
sudo apt list --upgradeable
If everything is okay, you should receive following result:

Step 2: See the active Kernel version
Issue following command to retrieve your current kernel version.
uname -r
Then you’ll get an output similar to,

That means, in more generic term, your Linux kernel is version 4.4.
Likewise, after the upgrade, we can issue the same command and verify whether kernel has been upgraded successfully.
Step 3: Install new Kernel
Create a directory for new kernel version 4.11.2 and make that as the current working directory:
sudo mkdir -p ~/4.11.2
cd ~/4.11.2
Download the required kernel version packages (Issue following commands orderly).
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.2/linux-headers-4.11.2-041102_4.11.2-041102.201705201036_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.2/linux-headers-4.11.2-041102-generic_4.11.2-041102.201705201036_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.2/linux-image-4.11.2-041102-generic_4.11.2-041102.201705201036_amd64.deb

Then install the downloaded packages with dpkg:
dpkg -i *.deb
When the installation is complete, issue following command to update grub.
sudo update-grub
Note: If you have to face “update-grub command not found” issue, following command will fix that problem.
sudo apt-get install --reinstall grub

After grub has successfully be updated, reboot the server for updates to get applied.
sudo reboot
After server rebooted, check the kernel version:
uname -r

Then you’ll obtain an output as above indicating your new Linux kernel version is 4.11.2.
Step 4: Remove the old Kernel
It is unnecessary to keep old kernel after upgrading, so it’s better to remove the old kernel. For this purpose install a utility called “byobu”.
sudo apt-get install byobu

Then issue following command to list down currently installed kernel(s) in your system.
dpkg -l | grep linux-image

Then run this command to remove old kernel(s):
sudo purge-old-kernels
If you see the following result (No kernels are eligible for removal),

That means; you only have 2 kernel versions installed. By default, byobu will keep at least 2 kernel version on the system to ensure that you have a backup kernel when the first one fails.
If you want to keep only one (latest) kernel, that could be achieve by following command.
purge-old-kernels --keep 1 -q
Now update the grub so that you’ll get only one kernel version installed in the system.
sudo update-grub
Now you have successfully upgraded you Ubuntu kernel to the latest version 4.11.2 from the mainline kernel build.
If you have any problem with this tutorial, please make a note at comment section so that I can help you.