This post explains how to change default OS to boot in GRUB. There are 2 ways to select Default OS to Boot:
Last Selected OS
To save the last selected OS and boot it next time, follow the below procedure:
- In ubuntu, open terminal with
Ctrl
+Alt
+T
- Type the below command:
$ sudo vim /etc/default/grub
- Enter password if required. In case vim is not installed you can also use vi.
$ sudo vi /etc/default/grub
- Once you enter the above command you will get the file with default settings:

- To learn how to edit the file using vim / vi, refer here. (If you are still finding difficulty to learn vim commands, please leave a comment below. I would be happy to help you out).
- From above image you can notice that
GRUB_DEFAULT=0
. Change that toGRUB_DEFAULT=saved
. - Now, add a line below that with this setting:
GRUB_SAVEDEFAULT=true
. - Your file should look like this:

- Once you have finished editing your file in vim, press
ESC
button to stop editing. Then type:wq
to save and quit vim. - Type the below command in terminal to update the grub:
$ sudo update-grub

- Now restart your system. Ubuntu will be selected now. Change to windows. Once you entered windows, restart your system and you will notice the default OS as Windows.
Always Boot the Same OS
From the above steps you would have learnt to save the last chosen OS and boot it the next time. Now lets consider you want to boot the same OS no matter what the last selected OS was. For example, grub always selects Ubuntu and you want to change it to Windows. Just follow the below procedure:
- In ubuntu, open terminal with
Ctrl
+Alt
+T
- Type the below command:
$ grep menuentry /boot/grub/grub.cfg

- The above screenshot shows the items displayed in the boot menu. From the above image, keep in mind the below values for your OS:
- 0 = Ubuntu
- 1 = Advanced options
- 2 = Windows
- Copy the slection you want from the terminal. For example, Windows Boot Manager (on /dev/sda2)
- Enter the below command:
$ sudo vim /etc/default/grub
- Now, there are 2 ways you can change the default OS:
- Change
GRUB_DEFAULT="Windows Boot Manager (on /dev/sda2)"
OR - Change
GRUB_DEFAULT=2
as Windows is 2 (explained in step 3 above).
- Change
- Once you have finished editing your file in vim, press
ESC
button to stop editing. Then type:wq
to save and quit vim. - Type the below command in terminal to update the grub:
$ sudo update-grub
- Reboot your system and you will find Windows selected.
Comment in case you need any improvements or if you have any doubts.
All comments will be replied asap.
Do checkout our other technology blogs here.