How to update Ubuntu to the latest kernel version?

I am using Ubuntu on my server, and I want to update it to the latest version of the Linux kernel. I am using aapanel. In the security section, I can see a warning that my current kernel has a security flaw and I need to install the latest version. I am not sure how to do it. Can someone explain the steps to upgrade the kernel?

Is it safe to update the kernel directly, or do I need to do something else before updating? I also want to know how to check my current kernel version.

You can follow the steps below to update Ubuntu latest kernel version is easy:

1. Check current kernel version:

You can check the kernel version you are currently using by running this command in the terminal:

uname -r

2. Update System Packages:

Run this command to update the local package list. This command gets the latest information about available packages from the sources set up on your system.

sudo apt update

3: Run the upgrade

To update the installed packages, including the kernel, to the latest versions available, run this command:

sudo apt upgrade

4. Reboot your system

After the installation is complete, reboot your system to start using the new kernel:

reboot

After rebooting, you can check the new kernel version by using the uname -r command again. It should show the updated version.