0

I want to add this line to /etc/grub.d/00_header

set superusers="ubuntu"

where ubuntu is the result of $USER. I've tried this:

sudo bash -c 'echo "set superusers='"${USER}"'" >> /etc/grub.d/00_header'

but it added the line without quotes:

set superusers=ubuntu

0

You just need to escape the double quotes you want preserved as literal:

sudo bash -c 'echo "set superusers=\"${USER}\""'
  • If I do this command sudo bash -c 'echo "set superusers=\"${USER}\"" >> /etc/grub.d/00_header' the result of $USER will be root, not the user ubuntu... – Luffy Wallis May 23 at 7:57
  • @LuffyWallis: That is because you are using sudo bash -c although that sort of falls into a new question of it's own. – Jesse_b May 23 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.