How to change Grub2's default login option

Grub It is that menu that appears on our computer and that allows us to choose which distro (or operating system) we want to use at that moment. That is, many of you will see in Grub several options for Ubuntu, Debian, ArchLinux or another distro, as well as the option to start with Windows (in case you have it installed).

By default they will enter through the 1st option, generally through the most updated kernel that they have in their distro, in my case by default it enters through Debian kernel v3.2.0-4-686-pae regardless of whether you have other kernels or other operating systems, then the question:

How to configure our computer so that by default it accesses NOT by the first option but by the one we want?

Although there are graphical applications that do this, here I will show you how to do it using only the terminal.

First we must know what options we have, for this in a terminal we write the following:

grep menuentry /boot/grub/grub.cfg

Our options will appear, something like this:

grub2-menuentrys

As you can see, every line that starts with «menentry" it is an option. Let's say that I want to set by default so that my system always accesses (by default I repeat) through Windows XP, located in / dev / sda1.

For this we must edit another file, in this case we must edit: / Etc / default / grub

To do this in a terminal we write the following:

sudo nano /etc/default/grub

In case they don't have sudo installed for whatever reason, they should then run the command: su through which they will be asked for the root password, and then they will be able to execute: nano /etc/default/grub

You will see something like this:

As you can see in the image, I pointed out GRUB_DEFAULT = 0 which is the line that indicates the option by which it will be accessed by default. That is, suppose that I want my laptop to always enter Windows XP by default (option number 9, as indicated in the first image) then that line should be: GRUB_DEFAULT = 8

Also in the next line it says: GRUB_TIMEOUT = 5, this refers to the waiting time, the seconds that Grub2 will wait before opening the default option, that is, the seconds they have to use the Up and Down arrow keys to change the option that will be accessed.

To save the file after any change and exit press [Ctrl] + [X], then [S] and [Enter]

Once this has been changed, we simply have to execute:

sudo update-grub

This will update what new they did, make the changes effective.

And voila, we are done 🙂

This tutorial was a bit long for me, but it doesn't mean that changing Grub2's default input is complex, it's actually quite simple.

Anyway, nothing more to add about it.

regards

/ code


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Frank Davila said

    The use of the terminal in linux is important and interesting, but for that I use grub costumizer, you download only one package in Ubuntu and you install it, it helps you to customize grub in all its aspects, which is what interests me and you don't have so much can or waste time remembering commands.

  2.   Frank Davila said

    There are problems loading the page desdelinux.net review.

    1.    KZKG ^ Gaara said

      Yes ... the current hosting is not enough. Proof http://justice.desdelinux.net and you tell me how fast this blog clone is.

      Thanks for your help 🙂

  3.   eliotime3000 said

    Thanks for the advice. Anyway, I'll use it on my other old PC when I put Debian with Slackware on it.

  4.   majority said

    the tutor is good ... about the Grub

  5.   Geomixtli said

    Hello, I would like to add that in Archlinux to update the grub menu the following command is used:
    grub-mkconfig -o /boot/grub/grub.cfg (done as root)

    1.    sieg84 said

      on other distros it is: grub2-mkconfig -o /boot/grub2/grub.cfg

  6.   sieg84 said

    I really didn't think it was so simple to do it.

  7.   Miguel said

    I am going off the subject a bit, but I take the opportunity to ask, can you put an extra input to boot from CD or USB in Grub2?

    Greetings to all

  8.   Miguel said

    One doubt, seeing the example, I BELIEVE that the first option is 0, therefore for WinXP it would be 8. Is this correct?
    All the best

    1.    KZKG ^ Gaara said

      Indeed, thank you very much for the warning, I have already edited the post 🙂

  9.   marlon ruiz said

    Thanks, you put it as it is, SIMPLE

  10.   marlon ruiz said

    Could you explain how to change grub's face, please, 😀

    1.    KZKG ^ Gaara said

      Hello, how are you?
      We have already published several things about Grub, how to put a password, how to change its appearance, etc, take a look here - » https://blog.desdelinux.net/tag/grub/

      regards

  11.   asd said

    I test if he is in a fedora, the fedora grub is different from the oldbian grub

  12.   Jose Jaime said

    Thank you very much for the tutorial and making it easy for us KZKG ^ Gaara.

    Best regards

  13.   Ricardo Brito said

    Thank you very much, the topic was accurate. I learn from you.

  14.   Erick Azeem Portillo Acosta said

    very good my friend, very detailed
    Thank you

  15.   sanpeter said

    Muchaaaaaaaaaaaaas thanks!
    It helped me a lot.

  16.   Martin said

    Perfect on grub 2.02 beta ubuntu 14.4

  17.   ims said

    Thank you very much, effective, direct, easy to understand… .. and better than a live disk with supergrub or more complex things. Thanks for your time for others

  18.   Alberto said

    Hi KZKG ^ Gaara, I recently bought a computer without OS, I installed windows 7 ultimate first and then Ubuntu 14.04.
    When I try to set it to boot with windows 7 by default, I modify the grub file but put the number that I put by default (either that of windows 7, in my case GRUB DEFAULT = 7, or any other) it does not move from ubuntu when I turn off and on the computer again. I have updated after modifying so that would not be.
    Do you know any reason why even if I modify the file the boot does not move from Ubuntu?
    Thank you very much in advance.

  19.   Miguel said

    hello how are you, I have a problem, I had installed ubuntu 14.10 and mint 17.1, and I decided to install elementary os luna, when doing so, the grub was modified and ubuntu changed from being the default option to being in the 5 position, and after applying The changes as you say in any way possible I cannot make Ubuntu the operating default again and leave elementary os as a last option. What can I do about it, thank you very much, I appreciate a prompt response. thanks.

  20.   Victor said

    Thank you very much!
    It has helped me a lot, I was already beginning to be worried. But thanks for this tutorial, although it is something "basic", it is important

  21.   Jose said

    Good Morning.
    Dear very successful, your very simple and easy knowledge helped me a lot, thank you

  22.   tincho said

    Thank you! Re simple and well explained.

  23.   Claudio said

    How do I configure grub2 to start from another disk to the one already configured?

  24.   Rafael said

    Regards. Excellent explanation

  25.   Jose tovar said

    After having configured the grub, now Windows does not come out ... Far from the first boot option ... What could I do to fix it ... Thanks

  26.   Ezekiel said

    Hi. Thanks for your time. I adhere to the IMS comment, easy and direct. Cheers

  27.   Saints said

    Simple explanation and very well exposed. Thank you

  28.   Mohamed burned said

    friend, the image is nice, but I like to use more 15s / px in TIMEOUT, it is a tip for you.
    You also have mixed kebab with free cocacolo potatoes, you pay in my kebab
    luck in your life ♥

    1.    ALA said

      What do you say INFIDEL, I stoned you and you don't even realize uuuhuhuhuhuhuhuhu

  29.   Adrian abadin said

    I ask a question can you do the same from Windows? I explain I want to be able to start one or another operating system by remote desktop, so if I am on Linux I can modify the Grub so that it starts Windows. Now if I am on Windows, can I modify it to start Ubuntu?

    1.    ALA said

      Hi ADrian, your question is very interesting, I'm sorry to tell you that from windows 98 you can't, it's a shame but you have to hold on….
      also the tablets conflict with MAC Yosemite, FUCK I'M UP TO THE EGGS ALREADY
      By the way do you like databases?

  30.   YOUSSEF BETTI DAIFI said

    Thanks for your explanation, quite broad and precise