How-To Geek

How-To Geek

Set Windows as Default OS when Dual Booting Ubuntu

When you install a dual-boot of Ubuntu, one of the frustrating things that you’ll immediately notice is that Ubuntu is now set as the default operating system in the Grub loader. There’s an easy way to switch back to using Windows as the default.

To make this change, you’ll first have to boot into Ubuntu, and then run the following command:

sudo gedit /boot/grub/menu.lst

Find this section of the file:

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
# You can specify ‘saved’ instead of a number. In this case, the default entry
# is the entry saved with the command ‘savedefault’.
# WARNING: If you are using dmraid do not change this entry to ‘saved’ or your
# array will desync and will not let you boot your system.
default 0

The important line is the last one. You will need to change that number 0 to match the Windows boot section. Typically it’s always going to be 4 on a default dual-boot configuration. Change this value to 4, and then save and reboot your machine. You should go into Windows instead of Ubuntu automatically.

Note: The blocks at the bottom of the file match the items in the menu. You can change this value to match whichever item you want as default, just remember that numbering starts at 0.

    This article was originally written on 01/7/07 Tagged with: Ubuntu, Ubuntu Tips & Tweaks, Windows

    Comments (79)

    1. domagoj

      All I needed, thank you!

    2. Nevis

      Funny, I’m struggling with the annoying sequence of Windows booting by default. :-)

    3. john

      hi there everyone. im new in linux and installed ubuntu.
      i just wanted to know what is the syntax of doing that command on how to change the default OS

    4. john

      i already got it. thanks i just made a mistake in typing .lst.

    5. murali

      I tried editing the file thourgh the file browser, but I couldnt open menu list file with write permission.
      even though i am the only user (owner)

    6. Neil Young

      Hi there…
      I am a newbie to Ubuntu / Kubuntu and linux completely. I’ve installed Ubuntu as dual boot to Windows XP. The installation went smoothly. I’ve Windows XP on a Sata HDD and I’ve install Ubuntu on a IDE (Sec. Master) HDD. In addition to this I’ve got two Data storage disks ie: 1X SATA HDD & 1X IDE HDD.

      My problem is that when I restart my PC and want to choose to load Windows XP I get a “NTDLR is missing” message and I’ve to restart. How do I solve this problem?

      Thank you in advance


    7. Matthew W

      Hi Neil,
      A quick search of reveals that this problem can have several causes. Here is a link to the most common:

      I hope this helps.


    8. Nospoon

      Murali – you have to open it via terminal, because normal users (yes, even the owner) do not have full permissions. Full permissions are granted only to root, and the simplest way to do things as root is to launch them with sudo.

    9. murali

      thanks nospoon. got it working a while back.

    10. Lauris Ancupans

      This helped me out. Thanks!

    11. Colin

      When I run the command it brings up a menu.Ist file in a text editor, but its blank and I can’t edit anything.

    12. Dan L

      I went through dozens of websites and this is the only and first one that clearly explained how do fix this issue and it worked perfectly. Thanks a ton.

    13. HELP!

      Hello, please help me… I am super new to Linux… I installed Ubuntu on my PC and I am affraid that all of my files are gone. I used to run XP and now I can’t find any of my files. Can anyone please tell me how to switch back to Windows just so that I can see my files again???
      Thank you so much,


    14. rob

      same for me! can find winxp anymore

    15. fatih

      thanks a lot. very clear explanation. seconds i did it.

    16. Frank H

      Thanks for the response so quick. Works Fine

    17. Satya

      I guess this number 4 would quickly go out of sync once you upgrade ubuntu (kernel). That means you will have to keep incrementing this number every time you got a new kernel through update process.

      I believe there is a better way, but can’t recollect.. Anyone?

    18. Jack

      Satya: It might be easier and neater to just remove the new kernels entirely.

    19. esau

      Jack – why would someone want to remove their newly installed kernel(s)? I agree with Satya; there is sure to be a better way to do this, or at least I hope there is. Or you’ll need to go LILO. Great little article apart from this minor inconvenience.

    20. Jack

      esau: My mistake, I meant old ones that you won’t be using any more. ;)


    21. Dave

      Surely it is not better to use the following:

      default saved

      This boots what ever entry has been saved using the command:

      Window is by default saved using savedefault in a Debian/Ubuntu /boot/grub/menu.lst

    22. Chris

      Mali and rob-

      It depends on if you used the wubi ubuntu installer or the partitioner/full install. If you used Wubi (Otherwise known as “Install in side Windows”) then all of your XP files will be in the directory “/host/Documents and Settings/@@” where @@ is your username. If you used the full install, you have to mount the other partition by going to the “Places” menu on the top panel and clicking on the ## GB media where ## is the size of the XP partition. Then there should be a shortcut to it on your desktop. If this is disabled and the shortcut does not appear, then you can go to /media/disk in the file browser and drag a shortcut out to your desktop.
      Hope this helps!

    23. Mike

      any ideas on how to change the boot loader if you where stupid enough to remove Ubuntu???



    24. Burrows

      MIke, not sure if this helps but my ubuntu on this list is shown as
      ## should update-grub add savedefault to the default options
      ## can be true or false
      # savedefault=false

      ## ## End Default Options ##

      title Ubuntu 8.10
      uuid f4151833-890f-4e9d-b6bb-84faf6f992fd
      kernel /boot/vmlinuz-2.6.27-9-generic root=UUID=f4151833-890f-4e9d-b6bb-84faf6f992fd ro quiet splash
      initrd /boot/initrd.img-2.6.27-9-generic


      # This is a divider, added to separate the menu items below from the Debian
      # ones.

    25. aruhadi

      I just cut and paste menu of windows and store it above this:

      title Ubuntu, kernel 2.6.20-16-generic
      root (hd0,2)
      kernel /boot/vmlinuz-2.6.20-16-generic root=UUID=7fd45131-277a-46a7-b01a-bc7eeaf39669 ro quiet splash
      initrd /boot/initrd.img-2.6.20-16-generic

      so become this:

      title Microsoft Windows
      root (hd0,1)
      chainloader +1

      title Ubuntu, kernel 2.6.20-16-generic
      root (hd0,2)
      kernel /boot/vmlinuz-2.6.20-16-generic root=UUID=7fd45131-277a-46a7-b01a-bc7eeaf39669 ro quiet splash
      initrd /boot/initrd.img-2.6.20-16-generic

    26. Nicklas

      but how do you run or start sudo gedit?

    27. Nicklas

      just need to know how to follow these instructions?

    28. John Bracken

      Click Applications –> Accesories –> Terminal

    29. Raj

      Hi guys I have question for UBUNTU experts people,. I recently installed Ubuntu and i lost my old win XP os & data.Luckily i have backup my data file before installed Ubuntu. My question is HOW TO INSTALL WIN XP OR VISTA WITHOUT remove UBUNTU.Even i tried to made partition in UBUNTU but no success. Also I would like to know how i can make partition in UBUNTU.

      Waiting for answer.

      Thanks in advanced.


    30. varma

      Excellent posting . Simply superb. I succeeded in doing that. I made XP as first boot. … Thank you very much …………… VARMA

    31. varma

      HI raj ,

      just follow this link. I found it useful.


      It may help you ….
      Regards …….. VARMA

    32. Sukku

      HI dudes,

      any one can help me out..

      i have installed two Operating systems, i.e., server 2003 and XP…. By using server 2003 i have installed oracle apps. for some days i have worked convienently. after few days i had a problem that my XP has stopped working. i tried to re-install, but it is not accepting now.. after few days Sound drivers has stopped working in server 2003. i tried to re-install, it is also not accepting.

      But XP is there in the boot list..

    33. Dan

      Thanks for this. Works great! Cheers

    34. brentoboy

      if you are having issues with upgrading the kernel moving the indexes so that xp is no longer default, you could take the xp entry, and move it up to be the first one, and move the default back to 0

      put it between these two lines:

      # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST



      so, after the move, mine looks like this

      # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

      # This entry automatically added by the Debian installer for a non-linux OS
      # on /dev/sda1
      title Microsoft Windows XP Professional
      rootnoverify (hd0,0)
      chainloader +1


    35. Davonte

      I want it to be remove from my computer.

    36. Michael Fox

      The Ubuntu crowd tries to be very helpful to neophytes, but their explanations seem to start one step too late. They say what to put into the COMMAND line but don’t say how to get to the command line. I want to boot into Windows.

    37. Len

      I tried to edit this, and i get it loaded, but when I go down to where it says:

      default 0

      I can’t change it. I try to go with it with the cursor and it wont change.

      It seems that the number cant be changed no matter what I do.

      Is there another way to change this setting?

    38. karthik

      Thanks buddy!! Thanks for sharing the info.. Was really helpful.

    39. emonweb

      Just wana to say thanks

    40. John S

      I have a somewhat different problem. I installed ubuntu alongside windows half and half, and upgraded the windows partition to windows 7. Now when the computer starts up i no longer have the option of picking an OS to begin with. The only way I can access ubuntu now is through the cd, and that’s still just the disc version. How can i switch ubuntu back to the default?

    41. Neep

      I change the 0 to 4 and it will not let me save, i tryed not changing anything and it will not let me save what did i do wrong?

    42. Cameron Gray


      That worked perfectly!

    43. digitalpbk

      On ubuntu 9.10 the procedures are different.
      Follow for updated instructions.

    44. Biju Subhash

      thank you for the info :D

    45. Sabine


      I’m also quite new to Ubuntu but I think this article (however very helpful) has an error:

      it says you have to punch in the command ‘sudo gedit/boot/grub/menu.lst’ but, at least in my case, this doesn’t work. The command that DID work was: ‘sudo gedit /boot/grub/menu.lst’. Just one space in difference, but it took me some time before I figured it out. Perhaps this sounds really stupid to other experienced users out there, but I daresay there are newbies who will make the same mistake I did!

      Then, even before you are able to punch in this command (which elevates your rights on this file so you can save it, my dear fellow newbies), you need the Terminal (aka “run” in windows). You’ll find it under Applications > Accessories > Terminal.

      It is also possible that the Terminal will ask for your password after punching in the command. At least in my case, it kept asking me for it.
      I then opened the “users and groups” (System > Administration > Users and groups) and I
      1. changed the password of the account I logged on with temporarily in something without special characters or numbers
      2. unlocked the root account (select it, click unlock and enter the master password).

      Then it worked like a charm for me and now I can simply turn on my PC, do my work under windows (which boots now by default) and then, when it’s time for fun, change to Ubuntu!

    46. amal mirando

      thanks a lot for helping me out in making windows my default OS.I was really fed up with ubuntu being loaded automatically.

    47. brando

      digitalpbk, thank you so much for that link. I was looking for like 30 minutes!

      Thanks a lot.


    48. Nisarg Shah

      Good article, needed it.

    49. Tony

      When I enter the command “sudo gedit /boot/grub/menu.lst”, gedit opens the file but it’s empty.
      Any thoughts?

    50. Paul

      Grub 2 is different, you don’t edit menu.lst anymore. See here

    51. Erik

      I know this is an old thread but here I go

      I have a laptop that was previously installed with Windows 7 and then added Ubuntu 10.04
      I also had the same problem like Tony, opening menu.lst and coming out empty.

      1. Does anyone know what to do instead?

      2. Is it possible to use Windows Bootloader rather than Grub 2 to boot Ubuntu?


    52. kwadwo

      Since grub 2 is different, what the solution to this? need help

    53. Chris Robinson


      I do not have a menu.1st in the /boot/grub directory

      I have a load of files with .mod.

      I was expecting menu*

      Ubuntu 2.6.32-22
      Ubuntu 10.04LTS


    54. Evgeniy

      Thanks to Paul’s comment

      I was able to change that on Ubuntu 10. You need to edit /etc/default/grub file and then execute
      sudo update-grub
      to propagate changes into Grub loader

    55. ubuntu

      i downloaded ubuntu but i didnt download it side by side with windows. how do i go back and down load it side by side. i need to get all of my old docs

    56. Phil

      Just tried to do this on the latest version of Ubuntu (10.10).

      The command now is sudo gedit /boot/grub/grub.cfg

    57. F

      Thanks Phil, your command line worked perfectly fine for me… Using Ubuntu 10.04 LTS

    58. Marek

      I run sudo gedit /boot/grub/menu.lst in terminal and I get a empty gedit file. now what?

    59. Marek


    60. Gabriel

      Thanks for the update


      Just tried to do this on the latest version of Ubuntu (10.10).

      The command now is sudo gedit /boot/grub/grub.cfg

      Good it works

    61. Tanner

      When i this in it says command not found ? any help

    62. Norteño del Sur

      Im looking 4 this a looooong time!
      Many thanks!!

    63. Dave

      I’m having the same problem when I type the command, it opens a text edit application

    64. wow

      the file is empty!!

      any help



    65. wow

      i`m using ubuntu 10.04 grab2 so this file (/boot/grub/menu.lst) is empty i guess i`l format mu hd *O*!

    66. Abhi0123

      Phil wrote:
      >”The command now is sudo gedit /boot/grub/grub.cfg”

      grub.cfg is a derived file and should not be changed directly. Change /etc/default/grub instead and then run ‘update-grub’. /boot/grub/grub.cfg would automatically be updated.

      1. Open a terminal. In Ubuntu, this can be done by pressing CTRL+ALT+T.
      2. Type “sudo gedit /etc/default/grub” (w/o the quotes). Provide your password if asked for.
      3. Change “GRUB_DEFAULT=0″ to “GRUB_DEFAULT=4″
      4. Save the file using the “Save” button in the editor. Exit the editor.
      5. Type sudo “update-grub” (w/o the quotes) in the terminal. Provide your password if asked for.
      6. Reboot and have fun with Windows 7 as the default OS to be booted.

    67. slackware_forevah


      To set Windows as the first O/S in grub’s boot list, rename the file in /etc/grub.d/??-os-prober with a number between 5 and 10, then run update-grub . This way, kernel updates should not interfere with Windows being booted by default.

    68. Vision


      Perfect! Thanks so much!

    69. Jerome Demers


      Thanks, it works perfectly!
      in my case, I reboot and count where was win7 on my list then wrote GRUB_DEFAULT=6.

    70. happy balls

      you wanna know how to geek? hit the chicken bone a few times and you’ll find out

    71. phinus

      once you have win7 as the default os to be loaded, and the bootmenu is automatically bypassed, how do you access ubuntu again if the computer always boots into win7?

    72. Darshan

      Hi, i tried to do the things whatever u ve said but it didnt work… Bcoz the file, menu.lst s nt there only!!!!!! What to do??????????????
      Pls reply…!!

    73. Darshan

      I’m using ubuntu 2.8 and win 7

    74. Abhivsm94

      Hi .. I’m using ubuntu 10.10 and windows 7 ultimate
      does this work on ubuntu 10.10……….

    75. Riking

      This doesn’t work on Ubuntu 10.10, because it uses GRUB2.
      See the bottom of this page:

    76. rente

      A ot of us mentioned that when we type in the sudo lines we are taken to an empty page.
      Why ?and how can we get to the line in grub to change the default boot os.?

    77. WS

      wotld this work in reverse to make linux the default boot option?

    78. unknown

      thank Riking for the link, it works very well…

    79. SAI

      Thanks and thanks alot. Such a simple and apt explanation :)

    Leave a Reply

    <A HREF=",2865004320,788367^1033287^87^0,1_/xsxdata=1:30/bnum=252724/optn=64?trg=http%3A%2F%2Fads%2Ebridgetrack%2Ecom%2Fads%5Fv2%2Fimg%5Fclick%2F%3FBT%5FBCID%3D325971&BT%5FSID%3D100177&" target="_blank"><IMG WIDTH=728 HEIGHT=90 SRC="" ALT="" BORDER=0></A>