Every time Vivaldi gets updated, I have to run this sed command to apply custom.css

sudo sed -i '1s/^/@import "custom.css";/' /opt/vivaldi-snapshot/resources/vivaldi/style/common.css

Now the command works fine in the terminal but not when I try to run it by creating an alias in ~/.bash_aliases or even through a bash script (placed inside /bin/ with executable permission). I did try using full-path for "custom.css" but it still didn't work. Thanks.


(1) Through alias:

alias vivupdate="sed -i '1s/^/@import "custom.css";/' /opt/vivaldi-snapshot/resources/vivaldi/style/common.css"

When I tried to run, I'm getting this error:

$ sudo vivupdate
[sudo] password for admn:

sudo: vivupdate: command not found

(2) Through a Bash script:

sed -i '1s/^/@import "custom.css";/' /opt/vivaldi-snapshot/resources/vivaldi/style/common.css

created vivupdate.sh, made it executable and placed it inside /bin/.

Then edited sudoers file and added:

user ALL=(ALL:ALL) NOPASSWD:/bin/vivupdate.sh

But when I run the script in terminal, I get this error:

sed: couldn't open temporary file /opt/vivaldi-snapshot/resources/vivaldi/style/sedCIt48u: Permission denied
  • 1
    Please edit your question to show the bash script and the alias and how you tried to run them.
    – sudodus
    Sep 21, 2019 at 17:20
  • 1
    Yes, we can't help you debug a command if you don't show us the command. Also, please explain what you mean by "didn't work". Was common.css not modified? Was it modified but the change was ignored? Was it modified in a different way to what you were expecting? What happens when you try the alias? Any error messages?
    – terdon
    Sep 21, 2019 at 17:31
  • @terdon Ok, I have just added the details on (1) alias and (2) script with errors I'm getting. Thanks.
    – Jags
    Sep 21, 2019 at 17:46

1 Answer 1


Aliases aren't available to sudo. They are specific to your shell and user, and sudo is running commands as root. Therefore, if you need an alias to be run as root, you need to include the sudo in the alias definition itself. Also, you have the quoting wrong on the alias there, so it wouldn't work anyway. What you want is:

alias vivupdate="sudo sed -i '1s/^/@import \"custom.css\";/' /opt/vivaldi-snapshot/resources/vivaldi/style/common.css"

Note how I escaped the inner double quotes (\"). Without that, since you are defining the alias with double quotes, the second double quote (the one before "custom.css) will signify the end.

The issue with the script is because of how sed -i behaves. Although it seems to be editing the original file, what actually happens is that it saves the edited file as a temporary copy and then renames the file back to the original. However, since you're not running it with sudo, you don't have permission to do so. The line you added to the sudoers file only means you can run sudo vivupdate.sh without a password. However, you still need to run it as sudo.

It isn't enough to add the command to sudoers, you still need to call it with sudo:

sudo /bin/vivupdate.sh
  • 1
    Thanks you so much for the detailed reply.
    – Jags
    Sep 21, 2019 at 18:19

You must log in to answer this question.

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