Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dual boot Linux/windows system set up, and frequently switch from one to the other. I was thinking if I could add a menu item in one of the menus to reboot directly into windows, without stopping at the GRUB prompt.

I saw this question on a forum, that's exactly what I want but it's dealing with lilo, which is not my case.

I thought of a solution that would modify the default entry in the GRUB menu and then reboot, but there are some drawbacks, and I was wondering if there was a cleaner alternative.

(Also, I would be interested in a solution to boot from Windows directly into Linux, but that might be harder, and does not belong here. Anyway, as long as I have it in one way, the other way could be set up as the default.

UPDATE It seems someone asked a similar question, and if those are the suggested answers, I might as well edit /boot/grub/grubenv as grub-reboot and grub-set-default and grub-editenv do. )

Thanks in advance for any tips.


This is my GRUB version: (GRUB) 1.99-12ubuntu5-1linuxmint1

I tried running grubonce, the command is not found. And searching for it in the repositories gives me nothing. I'm on Linux Mint, so that might be it...

Seeing man grub-reboot, it seems like it does what I want, as grubonce does. It is also available everywhere (at least it is for me, I think it is part of the grub package). I saw two related commands: grub-editenv and grub-set-default.

I found out that after running sudo grub-set-default 4, when running grub-editenv list you get something similar to:


And when running grub-reboot 4, you get something like:


Which means both do the same thing (one is temporary one is not).

Surprisingly, when I tried:

sudo grub-reboot 4
sudo reboot now

It did not work, as if I hadn't done anything, it just showed me the menu as usual, and selected the first entry, saying it will boot this entry in 10s.

I tried it again, I thought I might have written the wrong entry (it is zero-based, right?). That time, it just hanged at the menu screen, and I had to hard-reset the PC to be able to boot.

If anyone can try this out, just to see if it's just me, I'd appreciate it. (mint has been giving me a hard time, and that would be a good occasion to change :P).

Reading the code in /boot/grub/grub.cfg, seems like this is the way to go, but from my observations, it's just ignoring these settings...

share|improve this question
what distro are you on? I think i've got it working on my Debian. – jw013 Jul 16 '12 at 22:14
up vote 10 down vote accepted

In order for the grub-reboot command to work, several required configuration changes must be in place:

  • The default entry for grub must be set to saved. One possible location for this is the GRUB_DEFAULT= line in /etc/default/grub
  • Use grub-set-default to set your default entry to the one you normally use.
  • Update your grub config (e.g. update-grub).

This should take care of the initial set-up. In the future, just do grub-reboot <entry> for a one-time boot of <entry>.

share|improve this answer
  1. Edit the /etc/default/grub and replace GRUB_DEFAULT=0 with GRUB_DEFAULT=saved
  2. sudo update-grub
  3. your command will be:

    sudo grub-reboot "$(grep -i 'windows' /boot/grub/grub.cfg|cut -d"'" -f2)" && sudo reboot

a pretty function in your ~/.bashrc will look like

# ******************************************************************
# reboot directly to windows 
#   Inspired by http://askubuntu.com/questions/18170/how-to-reboot-into-windows-from-ubuntu
# ******************************************************************
function my_reboot_to_windows {
    WINDOWS_TITLE=`grep -i 'windows' /boot/grub/grub.cfg|cut -d"'" -f2`
    sudo grub-reboot "$WINDOWS_TITLE"
    sudo reboot

In case, your grub.conf contains multiple lines for Windows, following functions will take care only about lines starting by menuentry and picking just the first one, referring to Windows:

function my_reboot_to_windows {
    WINDOWS_TITLE=`grep -i "^menuentry 'Windows" /boot/grub/grub.cfg|head -n 1|cut -d"'" -f2`
    sudo grub-reboot "$WINDOWS_TITLE"
    sudo reboot
share|improve this answer
My file /boot/grub/grub.cfg contains more lines with "Windows" in it, many of them stating something like ...=1 i915.semaphores=1 acpi_osi='!Windows 2012' $vt..., so I assume your code would fail on it. This can be fixed by grepping for ^menuentry 'Windows. – Jan Vlcinsky Jan 13 '15 at 16:11
This should be marked as the correct answer. – Taha Rehman Siddiqui Apr 14 at 19:46

I use openSUSE which comes with a script called grubonce, which does exactly what you need - set grub entry to be used on next reboot.

# grubonce
0: Trace -- openSUSE 12.1 - 3.1.10-1.16
1: Debug -- openSUSE 12.1 - 3.1.10-1.16
2: Desktop -- openSUSE 12.1 - 3.1.10-1.16
3: Failsafe -- openSUSE 12.1 - 3.1.10-1.16

# grubonce 0
Using entry #0: Trace -- openSUSE 12.1 - 3.1.10-1.16

# grubonce 2
Using entry #2: Desktop -- openSUSE 12.1 - 3.1.10-1.16

I don't know which (if any) other distributions ship this script, so in case your distro does not have it, you can check out this page:


share|improve this answer

grub-set-default seems more available (grubonce isn't listed in Ubuntu 'verse). It may also be more helpful as Windows 7 has a habit of performing a reboot during startup if updates were applied at last shutdown (that is, it begins startup, processes some update data, reboots, and then displays login page).
I've often started Windows 7 only to come back and find Ubuntu running.

share|improve this answer
I turned off Windows update, so that should not be a problem :D, I'll try this. From what I saw, it seems like this does the same thing as grub-reboot. I'm editing my question with more detail. Thanks anyway. – jadkik94 Jul 16 '12 at 20:52

In Fedora, you can use the following script. Note that this is mostly the same as described in http://askubuntu.com/a/18186/149422, with a few modifications for GRUB 2 in Fedora.

if [ `readlink /boot/grub2/grubenv` == "/boot/efi/EFI/fedora/grubenv" ]; then
    sudo mv /boot/grub2/grubenv /boot/grub2/grubenv-original
    sudo ln -s ../efi/EFI/fedora/grubenv /boot/grub2/grubenv
MENU_ENTRY=`grep ^menuentry /boot/grub2/grub.cfg  | grep --line-number Windows`
MENU_NUMBER=$(( `echo $MENU_ENTRY | sed -e "s/:.*//"` - 1 ))
sudo grub2-reboot $MENU_NUMBER
sudo reboot
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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