Skip to content

Instantly share code, notes, and snippets.

@mmdemirbas
Created October 8, 2012 09:33
Show Gist options
  • Save mmdemirbas/3851637 to your computer and use it in GitHub Desktop.
Save mmdemirbas/3851637 to your computer and use it in GitHub Desktop.
Configures grub to set last used entry as default automatically in each boot
# @author: mmdemirbas@gmail.com
filename=/etc/default/grub
# Replace GRUB_DEFAULT value to 'saved'
echo :: Setting GRUB_DEFAULT=saved
sudo sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/g' $filename
# Append GRUB_SAVEDEFAULT=true after deleting old GRUB_SAVEDEFAULT's
echo :: Setting GRUB_SAVEDEFAULT=true
sudo sed -i '/GRUB_SAVEDEFAULT=.*/d' $filename
sudo sed -i '$aGRUB_SAVEDEFAULT=true' $filename
# Update config
echo :: Calling update-grub
sudo update-grub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment