I’m trying to update my grub boot order back to booting the first option instead of the second, so I run sudo nano /etc/default/grub, but it brings up this, which is not the file I want to edit.

I’m on fedora 38

  • Jordan_U@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    9 months ago

    This should get you back to defaults:

    sudo cp /usr/share/grub/default/grub /etc/default/grub && sudo update-grub

    At some point you definitely did accidentally write to /etc/default/grub when you meant to write to /boot/grub/grub.cfg.

    There’s no shame in that; Grub’s configuration process is very confusing and counter-intuitive.

    Everybody who has used Linux long enough has stories of breaking their systems in sillier ways, and this didn’t even really break your system 🙂.

    • Interstellar_1@pawb.socialOP
      link
      fedilink
      arrow-up
      0
      ·
      9 months ago

      THanks! but I’m getting the error cp: cannot stat '/usr/share/grub/default/grub': No such file or directory when running this.

      • Jordan_U@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        9 months ago

        What version of Ubuntu are you using?

        What is the output of the following command?:

        dpkg -l | grep grub

        If you urgently want your grub menu to default to the first entry that can be done first, but unless that’s needed I’d prefer to get to the root of the problem(s) and get a proper fix.

  • villainy@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    9 months ago

    This looks like grub2-mkconfig was run with the output mistakenly set to /etc/default/grub. Someone ran

    grub2-mkconfig -o /etc/default/grub

    Instead of

    grub2-mkconfig -o /boot/grub2/grub.cfg

  • Throwaway1234@sh.itjust.works
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    9 months ago

    so I run sudo nano /etc/default/grub

    For improved security during file edits that require root access, it’s highly advised to use sudoedit (or sudo -e). This method is considered the standard practice to avoid the security pitfalls associated with directly invoking editors with sudo. To ensure the use of nano with sudoedit, simply set the VISUAL environment variable with export VISUAL=nano before running sudoedit . Alternatively, for a one-off command: VISUAL=nano sudoedit /path/to/file.

    Please note that while sudoedit is a safer starting point, it’s not the only method available. Alternatives such as doas, doasedit, or leveraging polkit with pkexec can offer even more controlled and secure ways to manage file editing with elevated privileges. However, it’s perfectly acceptable to stick with sudoedit, as it’s a commonly trusted tool.

    Be aware that direct usage of sudo nano or other editors is strongly discouraged. It bypasses important security mechanisms and can lead to inadvertent system-wide risks.

    EDIT: changed VISUAL=nano sudoedit to VISUAL=nano sudoedit /path/to/file.

    • catloaf@lemm.ee
      link
      fedilink
      English
      arrow-up
      0
      arrow-down
      1
      ·
      edit-2
      9 months ago

      On shared systems with untrusted users, you’re right. On your own system when you already have full admin rights, sudo nano is fine and doesn’t have any security implications that I’m aware of.

      • Pantherina@feddit.de
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        9 months ago

        Well, if you look at the file… and search the internet for “fedora edit grub entry not possible” that works.

        You use grub2-mkconfig to create this file, and what you want to change it in another file that is used to create this one.

        The thing is, what do you want to edit?