Yesterday I was working from home and needed to boot my Ubuntu-based office computer into Windows. I really didn’t want to brave the bomb cyclone (again) so I did some quick searching to see if I could do this remotely—without manually interacting with the EFI boot screen.

Surely you should be able to tell GRUB which OS to start on next boot, right? Right. Here’s how.

First, use this one-liner to get the name of the GRUB menu item you want to run on next boot:

# awk -F\' '/^menuentry / {print $2}' /boot/grub/grub.cfg|cat -n|awk '{print $1-1,$1="",$0}'
0   Ubuntu
1   Windows Boot Manager (on /dev/nvme0n1p1)
2   System setup

Since I wanted to boot into Windows, I typed:1

 # sudo grub-reboot "Windows Boot Manager (on /dev/nvme0n1p1)"

Then, reboot the machine.

# sudo reboot

Nice! The machine should now boot into Windows.

💪💪💪💪


  1. You should be able to just specify the number of the GRUB option you’d like to select, but I was having trouble with that and couldn’t figure out why. I do know that for me, specifying both the grub-reboot and the reboot command on the same line wasn’t working. [return]