Skip to content

Instantly share code, notes, and snippets.

@shivarajnaidu
Last active February 14, 2020 04:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivarajnaidu/cfd4ddc12de1798a82d1dbe0b8fad0b2 to your computer and use it in GitHub Desktop.
Save shivarajnaidu/cfd4ddc12de1798a82d1dbe0b8fad0b2 to your computer and use it in GitHub Desktop.
Install Linux Kernel 4.9 In Ubuntu and It's Derivatives
#! /bin/sh
#to produce colored output in STDOUT
red="$(tput setaf 1)"
green="$(tput setaf 2)"
blue="$(tput setaf 4)"
reset="$(tput sgr0)"
bold="$(tput bold)"
myArch=$(getconf LONG_BIT)
cd
install_linux_4_9() {
mkdir linux4.9 && cd linux4.9
if [ "$myArch" = "64" ]; then
echo "Its 64 bit kernel"
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-headers-4.9.0-040900_4.9.0-040900.201612111631_all.deb;
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-headers-4.9.0-040900-generic_4.9.0-040900.201612111631_amd64.deb;
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-image-4.9.0-040900-generic_4.9.0-040900.201612111631_amd64.deb;
elif [ "$myArch" = "32" ]; then
echo "Its 32 bit kernel"
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-headers-4.9.0-040900_4.9.0-040900.201612111631_all.deb;
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-headers-4.9.0-040900-generic_4.9.0-040900.201612111631_i386.deb;
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9/linux-image-4.9.0-040900-generic_4.9.0-040900.201612111631_i386.deb;
fi
[ "$?" = "0" ] && sudo dpkg -i *.deb && echo "$bold $green Linux 4.9 Successfully Installed $reset"
[ "$?" = "0" ] && echo " Run ${bold}${green}sudo reboot${reset} to Reboot Your System Now "
[ "$?" = "0" ] && echo "$bold $red If You Encounter Any Issues With Linux 4.9 and Want To Remove Linux 4.9 Just Run This Script With d $reset"
}
delete_linux_4_9() {
echo "Removing Linux 4.9..."
[ "$?" = "0" ] && sudo apt-get -y remove linux-image-4.9.0-040900-generic && sudo apt-get autoremove
[ "$?" = "0" ] && echo "$bold $green Linux 4.9 Successfully Removed From Your System"
[ "$?" = "0" ] && echo " Reboot Your System Now $reset"
}
current_kernel_version="$(uname -r | cut -c1-3)"
if [ "$current_kernel_version" = "4.9" ]; then
[ "$1" = "d" ] && delete_linux_4_9 || echo "$bold $green Linux Kernel 4.9 Already Installed In Your System $reset"
else
[ "$1" = "d" ] && echo "$bold$red You Have Not Installed Linux Kernel 4.9 Yet.." &&
echo "Currently Linux Kernel $current_kernel_version Installed In Your System $reset" || install_linux_4_9
fi
echo "$bold $green https://gist.github.com/shivarajnaidu/"
echo " Follow Us On Fb: https://fb.com/opensourceinside"
echo " Take A Look At: https://opensourceinside.blogspot.com $reset"
# echo "$bold $green https://gist.github.com/shivarajnaidu/cfd4ddc12de1798a82d1dbe0b8fad0b2 $reset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment