September 12

Linux: Ubuntu – How to change the grub boot order

You can  change the grub default boot entry from the command line without having to install any additional tool. This won’t change the order in the list but it will allow a different OS to boot by default, which sounds like what you may want anyway.

First, make a backup copy of /etc/default/grub. In case something goes wrong, you can easily revert to the known-good copy.

sudo cp /etc/default/grub /etc/default/grub.bak

Then edit the file using vim or the text editor of your choice.

sudo vim /etc/default/grub

Find the line that contains GRUB_DEFAULT=0 and set it to GRUB_DEFAULT=x where x is the index of grub menu item to which you would like to boot to by default. Note that the menu items are zero-indexed. That means that the first item in the list is 0 and that the sixth item is actually 5. So to boot to the sixth item in the list, the line would read GRUB_DEFAULT=5.

Additionally, if you want to use a kernel in the “Previous Linux Versions” menu, you’ll want to change GRUB_DEFAULT=0 to GRUB_DEFAULT=”2>x” (make sure to include the quotations), where x is the placement of the old kernel on the sub-list (assuming the “Previous Linux Versions” is third on the main list). Remember that the list always begins counting at 0.

Then build the updated grub menu.

sudo update-grub

By: Marve and DaimyoKirby


Copyright 2021. All rights reserved.

Posted September 12, 2013 by Timothy Conrad in category "Linux

About the Author

If I were to describe myself with one word it would be, creative. I am interested in almost everything which keeps me rather busy. Here you will find some of my technical musings. Securely email me using - PGP: 4CB8 91EB 0C0A A530 3BE9 6D76 B076 96F1 6135 0A1B