How to make an entry as default in Grub2 boot menu

Home / Guides / How to make an entry as default in Grub2 boot menu

This article is only useful if you are using Grub2. Which is the default boot loader in recent Linux releases including Ubuntu 9.10 and newer.

Recently I received a dual boot system in having Ubuntu as default and windows xp. I needed to make windows xp to be the default boot option i.e. to boot into windows automatically after 10 seconds.

First of all we need to count the number of entries in the boot loader starting with 0. It means the first entry is 0, second is 1 and so on. In my case my windows entry was number 4. Note this number somewhere because we need to use it later.

Now we need to load the Ubuntu or what ever version of Linux you have installed. In my case it is the first entry in the boot menu as shown in the picture.

After the Linux desktop has loaded. Open a terminal window and type the following command. It may ask your password:

sudo nano /etc/default/grub

This will open the file “grub” in nano command line text editor.

Now look for the following line:


and type the number of the boot menu entry next to = sign. in our case it was the index number of the entry named “Microsoft Windows XP”. the number of this entry was 4.

First entry’s number is 0, second’s number is 1 and so on.

Now our modified GRUB_DEFAULT parameter looks like this:


This means that the default OS is fifth one in the list.

Now we need to save and exit nano editor. To do so, Press CTRL+X then press y to confirm changes.

Now run the following command in a terminal to update grub files.

sudo update-grub

Now reboot the system to see the changes. It should automatically start the OS mentioned on 5th line in boot menu. i.e. Windows XP in out case.

This way we can change the default OS when ever we need it.


One Comment

Leave a Reply