0

I am trying to set GRUB to not show at startup by using the command line. For this I try editing /etc/default/grub with sudo, but I get a Permission denied error as a response:

myuser@mysystem:~$ sudo echo "GRUB_HIDDEN_TIMEOUT_QUIET=true" >> /etc/default/grub
bash: /etc/default/grub: Permission denied

What I want to set:

sudo echo "" >> /etc/default/grub
sudo echo "# Hide Grub" >> /etc/default/grub
sudo echo "GRUB_HIDDEN_TIMEOUT=0" >> /etc/default/grub
sudo echo "GRUB_HIDDEN_TIMEOUT_QUIET=true" >> /etc/default/grub
sudo update-grub

Permissions of the file:

myuser@mysystem:~$ ll /etc/default/grub
-rw-r--r-- 1 root root 1211 Feb 12 20:00 /etc/default/grub

Shouldn't I be able to use sudo to edit this file? Why doesn't sudo give me the permission even though the file belongs to root:root?

EDIT:

Found out that the two above GRUB settings do not work for the desired goal. To still achieve GRUB not showing the following setting needs to be added to /etc/default/grub using:

sudo bash -c "echo 'GRUB_DISABLE_OS_PROBER=true' >> /etc/default/grub"
Zanna
  • 69,223
  • 56
  • 216
  • 327
Socrates
  • 2,351
  • 7
  • 31
  • 52
  • 1
    You DON'T want to modify this file the way that you're doing it. In `terminal`, do `sudo -H gedit /etc/default/grub`, modify the EXISTING lines that match what you need to change, save the file, then `sudo update-grub`. – heynnema Feb 12 '19 at 21:44
  • @heynnema The problem with your approach is that it requires a human user in front of the screen. The reason I want to set the above is for a setup script after installation. I do not want the user having to set anything. Current solution is explained within the duplicate link, making use of `sudo bash -c "echo 'GRUB_HIDDEN_TIMEOUT=0' >> /etc/default/grub"`. – Socrates Feb 13 '19 at 10:31
  • 1
    1) your desired script is changing a system-level file, 2) no script necessary for something that only requires a one time manual edit, 3) you don't want to ADD lines to the grub file that ALREADY EXIST in the file. – heynnema Feb 13 '19 at 14:08
  • 2
    Voting to reopen this question as it's about more than redirection. – Zanna Feb 14 '19 at 07:04

0 Answers0