I would like to know the difference between these two lines :
sudo sed 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=3/' /etc/default/grub >/etc/default/grub
and
sudo sed -i 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=3/' /etc/default/grub
There seems to be a difference because the first returns a Permission denied error while the other doesn’t.
As @sarathi said, the
-iflag modifies the file in-place. The reason you’re getting a permission denied error is because/etc/default/grubis probably only modifiable by root.Your first command:
Runs
sedas a superuser, which doesn’t do anything useful assedwrites to its stdout. Then it tries to overwrite/etc/default/grubas the current user, which is disallowed.In the second command:
The file is modified by
seditself, which is running as root.