I am having Windows and Ubuntu installed side by side. So every time when I boot (when the GRUB menu appears) I have to press down key to select a specific OS.

I want to edit the code of GRUB so that it remembers what I boot last. Like if I boot Ubuntu last time, then by default selected option will be Ubuntu in menu, similarly for windows.


You need to set save_default in /etc/default/grub (at the top of the file is OK):


After adding these two lines to /etc/default/grub, you then need to update Grub's configuration using this command:

sudo update-grub

This should add the line savedefault at the end of each entry in /boot/grub/grub.cfg.

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