By Anonymous

Upgrade to Kernel 3.9 on Luna Beta 2

Elementary OS Luna is based on the 12.04 Long Term Support release of Ubuntu, therefore it uses an older kernel. However, newer versions of the Linux kernel have been released and many users are seeking a way to upgrade their elementary OS kernel to the latest version for better performance and a wider range of hardware support.

Notice: As shnatsel has pointed out: You shouldn't update your kernel as specified here, as it is very insecure. Instead use a backport kernel from raring with: sudo apt-get install linux-generic-lts-raring. See a more detailed description here.
In this tutorial we will discuss how to upgrade your kernel to version 3.9 (the current one used in Ubuntu 13.04 - upgraded from 3.8.8, see release notes.) Luna Beta 2 was used for this tutorial, so you should only follow these instructions for that specific release. NOTE: This may break your system. Proceed with caution.

The easiest method is to used the mainline PPA provided by the Ubuntu Kernel Team. The mainline kernels are basically latest upstream kernels using the Ubuntu kernel configuration files. If you want more information I encourage you to read the wiki entry.

The mainline PPA has easy to install .deb files that you can use to upgrade your kernel. Here is the script we can use to automate this process:

Copy the content of this script, and save it to a text file called kernelupdater.sh, or anything to your liking that ends with an .sh extension. Save the text file to your home folder for easier access via the terminal. Now open up the terminal and issue the following command to make the file executable:
chmod +x kernelupdater.sh
Now use the next command to start the upgrade process:
sudo ./kernelupdater.sh Enter your password and follow the on screen instructions. Everything should go accordingly and your system will get upgraded to the 3.9 raring kernel version!

At this point, do a quick reboot to start your system with the newer kernel. If everything works fine after the reboot, (e.g. all your hardware components are fully functional), you are good to go. You can use 'uname -r' to check what kernel version you are running.

ProTip: Linux keeps the old kernel images to allow you to recover from breakages related to kernel upgrades. You can always boot into the system with the older kernel by pressing right shift during boot which brings up the GRUB menu with all the available kernels. In my opinion it does not hurt to keep the old kernels because by default GRUB boots with the newest kernel available, but if you would like to get rid of the old kernels, use this guide.