I installed a mainline kernel for testing purposes. I would like to set grub to boot from the older kernel by default.

I know I can set the GRUB_DEFAULT=0 setting for the first page of grub but how do I set it to boot by default from one kernel in the second page (Advanced page)?

I would prefer doing this without installing other software (ex. grub-customizer).

Related Questions:
How do I set Windows to boot as the default in the boot loader?
How do I change the grub boot order?

  • 3
    @belacqua: It is not a duplicate. This question is about setting an older kernel that is not present in grub's first page of options as default.
    – To Do
    Nov 13 '12 at 13:14
  • It seems like this case should be covered in the earlier questions, even if the method needs to be update for 12.10, older kernels, etc..
    – belacqua
    Nov 13 '12 at 15:26
  • 3
    The question's use case is different, and the answer is very specific in a way that doesn't apply to the other claimed duplicates. I came here to solve this particular problem; not to change the boot order; nor to boot Windows. +1 for "not a duplicate". Mar 16 '15 at 14:09

First, make a backup copy of /etc/default/grub. If 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 the text editor of your choice (e.g. gedit, etc.).

sudo -H gedit /etc/default/grub

Find the line that contains GRUB_DEFAULT - this is what you'll want to edit to set the default. You must know the full name of the kernel you want - e.g. Ubuntu, with Linux 3.13.0-53-generic - along with the full name of the "advanced menu" - e.g. Advanced options for Ubuntu.

You then combine those two strings with > and set GRUB_DEFAULT to them as: GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic" (including quotes).

Save it, then build the updated grub menu.

sudo update-grub

See also: GNU GRUB Manual 2.02 or more specifically section 15.1.0 on setting the default.

Note: There is a method utilizing numbers to access kernels and menus but this is not recommended as it is unreliable when kernel updates occur.

  • 24
    Using a numeric value can be problematic when updates occur. It's better to use a text default, ie: GRUB_DEFAULT="Previous Linux versions>Ubuntu, with Linux 3.2.0-18-generic"
    – Bealer
    Jul 4 '13 at 16:45
  • 31
    One can use sudo grub-mkconfig | less to see all of the possible options
    – Nitz
    Feb 17 '15 at 20:55
  • 9
    This is a good solution, but even better is to open a /boot/grub/grub.cfg and there you will see all the manuentry and all the submenus. If you edit them, you can easy set the default ones, even change the Titles of the options in the grub list when restarting a computer.
    – Aleks
    Apr 21 '15 at 21:03
  • 10
    It is definitely useful to examine /boot/grub/grub.cfg to determine the exact names to use. But do not change this file as it will be automatically regenerated by update-grub, including on updating packages. May 19 '15 at 16:36
  • 21
    The formatting for GRUB_DEFAULT is slightly outdated (since at least Ubuntu 14.04.2). Running update-grub I encountered a warning: Please don't use old title Previous Linux versions>Ubuntu, with Linux 3.13.0-53-generic for GRUB_DEFAULT, use Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic (for versions before 2.00) or gnulinux-advanced-b0ce60c3-184c-453b-af59-419b56a2584f>gnulinux-3.13.0-53-generic-advanced-b0ce60c3-184c-453b-af59-419b56a2584f (for 2.00 or later)
    – Wumms
    Jul 3 '15 at 21:32

The best solution for me was to set (in /etc/default/grub):


With this settings the last selected value is kept for the next boot. If you have a new kernel you don't have to edit your config.

Don't forget to re-run sudo update-grub

The solution is from reading: info grub-mkconfig

  • 8
    This is awesome
    – Mephisto
    Jan 31 '18 at 17:58
  • are you sure about the semicolon (;) at the end of the lines?!? Mar 18 '18 at 8:54
  • I can not look into my computer where I used it in this moment, but you are right ";" seems to be wrong or unnecessary!
    – Martin T.
    Mar 21 '18 at 10:36

Now that an Advanced menu is default in Ubuntu, you'll need to select it before the kernel you want using the > character.

Set e.g.:


in /etc/default/grub and re-run sudo update-grub.

It is important to note that for the GRUB menu entries numbering starts with 0. Therefore the 1 above points to the Advanced menu. As a precaution, you may want to initially set GRUB_TIMEOUT=5. Some may be unable to access GRUB by hitting a key at boot time. This is a safety net in case you accidentally point to something like Memory test instead. It is also necessary to include the above numbers in quotes. It will not work otherwise.

I tested on 16.04 LTS.

  • Works in Debian too. Mar 16 '18 at 2:36
  • I find this answer very useful, as after a kernel update it still points to the newest kernel. in my setup for example it is 1>0, meaning: advanced-first listing (is always the newest kernel). my system sometime stopped to automatically update the 0 entry of grub with the newest kernel, so i use this method. Oct 13 '18 at 9:25

To be able to set which boot option to use as default you need to know what there is... so:

To display the menu entries without actually booting, try something like:

$ lsb_release -s -rdc
Ubuntu 16.04.4 LTS

$ update-grub --version
grub-mkconfig (GRUB) 2.02~beta2-36ubuntu3.17

$ grep -Ei 'submenu|menuentry ' /boot/grub/grub.cfg | sed -re "s/(.? )'([^']+)'.*/\1 \2/"
menuentry  Ubuntu
submenu  Advanced options for Ubuntu
    menuentry  Ubuntu, with Linux 4.4.0-34-generic
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (upstart)
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (recovery mode)
menuentry  System setup

  • 4
    sed -nre "/submenu|menuentry/s/(.? )'([^']+)'.*/\1 \2/p" < /boot/grub/grub.cfg - The same effect using only sed
    – Hannu
    Jan 26 '20 at 9:34
  • Verified to still work on 20.04.
    – Hannu
    Aug 29 '20 at 15:43

In order to do it with a GUI, I use Grub Customizer (I'm in Mint but that doesn't count here).

The simplest and most direct way (thanks @eMKi for the suggestion in comment) — best suited for a permanent setting, in General Settings > default entry > predifined, simply select the desired kernel in the drop-down list.

enter image description here

Or, in case one needs the "previous booted entry" to be the one selected (might be useful in dual boot with Windows when doing an Windows update that requires restart, for example) — keeping the Advanced options in the grub list in case the default list is changed within Grub Customizer:

enter image description here

under General settings select the default entry: previous booted entry.

enter image description here

Then, reboot, and during boot select the "Advanced options" entry in the grub list:

enter image description here

and select the older kernel

enter image description here

On the next reboot, the "Advanced options" item will be the one selected by default in the grub list and the last selected kernel from under there will be booted (without opening the full list of kernels).

In case Windows is used, or other option in the grub list, remember to re-do the previous procedure.

  • 1
    Hi, you could also just select a default boot entry from the list of available options in the 'Predefined' line. It depends, if you wish to have it selected permanently then that would be a good option. If you like to choose different entries then your way is better. Thanks for the GUI solution.
    – eMKi
    Jan 11 at 19:17
  • @eMKi - I was not aware of that basic setting, which should be the most obvious. So, I added that to my answer.
    – cipricus
    Jan 12 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.