Skip to content

Instantly share code, notes, and snippets.

Last active March 11, 2023 04:53
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save mmstick/8493727 to your computer and use it in GitHub Desktop.
Save mmstick/8493727 to your computer and use it in GitHub Desktop.
Asks the user whether they want to install the latest RC or stable, then downloads the correct kernel and installs it.
cd /tmp
if ! which lynx > /dev/null; then sudo apt-get install lynx -y; fi
if [ "$(getconf LONG_BIT)" == "64" ]; then arch=amd64; else arch=i386; fi
function download() {
wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | grep "$1" | grep "$2" | grep "$arch" | cut -d ' ' -f 4)
# Kernel URL
read -p "Do you want the latest RC?" rc
case "$rc" in
y* | Y*) kernelURL=$(lynx -dump -nonumbers | tail -1) ;;
n* | N*) kernelURL=$(lynx -dump -nonumbers | grep -v rc | tail -1) ;;
*) exit ;;
read -p "Do you want the lowlatency kernel?" lowlatency
case "$lowlatency" in
y* | Y*) lowlatency=1 ;;
n* | n*) lowlatency=0 ;;
*) exit ;;
# Download Kernel
if [ "$lowlatency" == "0" ]; then
echo "Downloading the latest generic kernel."
download generic header
download generic image
elif [ "$lowlatency" == "1" ]; then
echo "Downloading the latest lowlatency kernel."
download lowlatency header
download lowlatency image
# Shared Kernel Header
wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | grep all | cut -d ' ' -f 4)
# Install Kernel
echo "Installing Linux Kernel"
sudo dpkg -i linux*.deb
echo "Done. You may now reboot."
Copy link

Hey! Awesome script. Curious though that trying to download latest generic non-rc, and it downloads 4.7.0-XX instead of 4.7..2, which according to kernel.ubuntu is the latest as of 7 days ago. (in the website I just realized that the files are not in date order, so 4.7 appears below 4.7.2 even tho the latter is the latest). Sadly I don't know enough bash to suggest how to improve it.

Copy link

Hello, how can i get the latest daily ubuntu kernel ?

Copy link

Hello. Thanks for this useful script. Is there a reason why the latest stable kernel is not automatically downloaded? For example, latest stable kernel as of today in ~kernel-ppa/mainline/ is 4.9.6. However, on running the script, 4.9.0 is installed. I'm assuming that the script only looks at the 1st two digits of the kernel revision?

Copy link

nicman23 commented Jan 28, 2017

a quick fix is to add grep v[1-9].[1-9].[1-9] in the lynx dump command

edit: before the tail -n1

Copy link

CGarces commented Sep 12, 2017

@alothings @ronnocnave

See at the page render 4.7.x folder after v4.7.10 folder.

He problem is how the script detect the last valid folder

The solution provided by @nicman23 not looks valid, will ignore folders like 4.13 or 4.13.1

Also;O=A not works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment