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

1 Answer 1


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... May 23, 2019 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, 2019 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .