can not edit /etc/default/grub

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
oldfogie
Level 1
Level 1
Posts: 13
Joined: Fri Feb 10, 2017 12:35 pm

can not edit /etc/default/grub

Post by oldfogie »

I have an old laptop that dual boots windows 7 and Linux Mint 19 Cinnamon
I'm trying to change the grub default.

I've tried sudo grub-set-default - didnt work

I've tried editing /etc/default/grub as sudo nano /etc/default/grub or sudo vi /etc/default/grub
and the file is displayed but I cant make changes

in /etc/default/grub ls-l shows the permissions as -rw-r--r--

help please?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Pjotr
Level 24
Level 24
Posts: 20135
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: can not edit /etc/default/grub

Post by Pjotr »

Try this:

Code: Select all

xed admin:///etc/default/grub
The multiple slashes are no typo. Use copy/paste in order to ensure that the command is being transferred correctly.

If you wish to make Windows the default boot, this is how:
https://easylinuxtipsproject.blogspot.c ... 1.html#ID1
(item 1)
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
sebastjava
Level 5
Level 5
Posts: 713
Joined: Wed Jun 28, 2017 8:01 pm
Location: Montréal, Québec, Canada
Contact:

Re: can not edit /etc/default/grub

Post by sebastjava »

After you succeeded in editing and saving etc/default/grub, you must run this:

Code: Select all

sudo update-grub
You want to change the default starting OS ?
Also, this might be a bit off-topic, but if you are talking about the default starting OS, i found it very useful to make it start with your last chosen OS. This way, I usually automatically get it started or restarted on Mint, but when I go into Windows, which rarely happens, then there are tons of updates, and many required restart, restart, and restart again. So, with my custom settings, when Windows needs to restart to complete some update, it does so, automatically.

I found this tweak from there: https://askubuntu.com/questions/148662/ ... ast-choice

Put the following in /etc/default/grub (command line: xed admin:///etc/default/grub):

Code: Select all

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
Do some find/replace: those parameters are probably already there, so you need to edit them, not adding new lines.

Save this file and then run:

Code: Select all

sudo update-grub
The future Linux Mint Forums is here.
Self-Appointed Benevolent Designer on Linux Mint Cinnamon.
Image
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: can not edit /etc/default/grub

Post by Flemur »

oldfogie wrote: Sat Oct 16, 2021 4:27 am I've tried sudo grub-set-default - didnt work
Rather than tell what didn't happen, what DID happen when you ran sudo grub-set-default?
I've tried editing /etc/default/grub as sudo nano /etc/default/grub or sudo vi /etc/default/grub
and the file is displayed but I cant make changes
Again, what happened?

Either of those should work; try sudo vi /etc/default/grub then type an 'a', then type some other characters; they should be added after the initial # in the file. Then type the ESCAPE character to get out of insert mode. If you want to save it (the change you'd make from doing what I described will just change the comment, won't affect any settings), type :w.

Edit: type :q! to exit changed file without saving, or just :q to exit after saving.
Last edited by Flemur on Sat Oct 16, 2021 10:11 am, edited 1 time in total.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1374
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: can not edit /etc/default/grub

Post by ricardogroetaers »

How difficult is it to open, as root, the "/etc/default/" folder with File Manager and open the "grub" file with a simple Text Editor (Xed for example) and edit the file?
Don't complicate things!

Note: The changes you make to this file are your responsibility.
mikeflan
Level 17
Level 17
Posts: 7155
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: can not edit /etc/default/grub

Post by mikeflan »

The changes you make to this file are your responsibility.
This is a good point. I highly recommend backing up fstab before modifying it:

Code: Select all

sudo cp /etc/fstab /etc/fstab.bak
It should produce no output. That means it worked. You could need that bak file later :!:
User avatar
karlchen
Level 23
Level 23
Posts: 18228
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: can not edit /etc/default/grub

Post by karlchen »

What is the point in creating a backup copy of the file /etc/fstab, although the topic of this thread is editing the file /etc/default/grub? - Minor confusion.
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 792 days now.
Lifeline
User avatar
sebastjava
Level 5
Level 5
Posts: 713
Joined: Wed Jun 28, 2017 8:01 pm
Location: Montréal, Québec, Canada
Contact:

Re: can not edit /etc/default/grub

Post by sebastjava »

mikeflan wrote: Sat Oct 16, 2021 10:13 am [...] This is a good point. I highly recommend backing up fstab before modifying it [...]
fstab ? Why ? Please read the two first lines on /etc/default/grub:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

So, the file you are modifying is /boot/grub/grub.cfg. But don't touch this file directly ! Do as said before: edit /etc/default/grub and then run sudo update-grub for those changes to be made. And, yes, it would be a good idea to backup this /boot/grub/grub.cfg before doing anything.
The future Linux Mint Forums is here.
Self-Appointed Benevolent Designer on Linux Mint Cinnamon.
Image
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: can not edit /etc/default/grub

Post by Flemur »

karlchen wrote: Sat Oct 16, 2021 10:22 am What is the point in creating a backup copy of the file /etc/fstab, although the topic of this thread is editing the file /etc/default/grub? - Minor confusion.
He probably meant sudo cp /etc/default/grub /etc/default/grub.bak which is a good idea, especially for someone not familiar with the text editors.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
sebastjava
Level 5
Level 5
Posts: 713
Joined: Wed Jun 28, 2017 8:01 pm
Location: Montréal, Québec, Canada
Contact:

Re: can not edit /etc/default/grub

Post by sebastjava »

In the event of a major disaster

Let's suppose you got confused and did some really bad mistake. That is just an unlikely possibility. Murphy's law. Well, in the event of a major disaster, you could always restart from a USB key or CD with a live Mint installer, and then replace this /boot/grub/grub.cfg with your backup copy. :)

To be done as a last resort only.
Last edited by sebastjava on Sat Oct 16, 2021 11:17 am, edited 1 time in total.
The future Linux Mint Forums is here.
Self-Appointed Benevolent Designer on Linux Mint Cinnamon.
Image
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: can not edit /etc/default/grub

Post by Flemur »

sebastjava wrote: Sat Oct 16, 2021 10:39 am replace this /boot/grub/grub.cfg with the one from your USB key.
I'm pretty sure that wouldn't work. I don't have a Mint installer handy, but the Ubuntu 18.x one boots everything from /casper rather than /boot.

The thing to do is make backups on the installed OS of everything you're going to change (e.g. just cp X X.bak, as mentioned above, before you edit file X) then if you can't boot the OS, boot the installer, go to the broken OS and cp X.bak X to restore from the un-edited file. (Personally I'd never bother - which is why I didn't think of it - because I have a full backup of the OS that I can use to restore any OS file).
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
User avatar
sebastjava
Level 5
Level 5
Posts: 713
Joined: Wed Jun 28, 2017 8:01 pm
Location: Montréal, Québec, Canada
Contact:

Re: can not edit /etc/default/grub

Post by sebastjava »

Flemur wrote: Sat Oct 16, 2021 10:54 am [...] I'm pretty sure that wouldn't work. [...]
Okay. I re-edited my preceding post accordingly: use a backup copy.
The future Linux Mint Forums is here.
Self-Appointed Benevolent Designer on Linux Mint Cinnamon.
Image
mikeflan
Level 17
Level 17
Posts: 7155
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: can not edit /etc/default/grub

Post by mikeflan »

And I had a senior moment with that fstab backup. It is a good idea, but unrelated to this thread.
Aztaroth
Level 5
Level 5
Posts: 764
Joined: Mon Jan 11, 2021 1:48 am

Re: can not edit /etc/default/grub

Post by Aztaroth »

Any Timeshift snap also keeps copy/backup of all system files. A snap can be restored with the Timeshift app but it can also be read as a 'normal' directory.
In each snap directory (named after the date it has been created), there is a localhost subdirectory containing all system files in the same locations (/bin, /boot, /etc...) than the running system. A single file (grub, fstab, cron...) can be manually restored if necessary.
dual boot LMDE4 (mostly) + LM19.3 Cinnamon (sometimes)
Locked

Return to “Installation & Boot”