2
Hello and sorry for my English in advance.
I need to execute from root command like
envVariable1=15 envVariable2=25 sudo -u user1 sudo -E myCommand
but environment variables don't pass to myCommand. This may look illogical, but it's necessary to run command from root and with sudo cause it will be used in scripts. How can I work around the problem?
Possible duplicate of How do I make sudo preserve my environment variables?
– Anthony Geoghegan – 2016-10-25T13:53:23.0672Why the double
sudo
? What's wrong withenvVariable1=15 envVariable2=25 sudo -E myCommand
? If there's a good reason for the the firstsudo
, this also needs a-E
. Alternatively, if you don't need to preserve other environment variables, add anenv
command to the finalsudo
, as insudo -u user1 sudo env envVariable1=15 envVariable2=25 myCommand
. – AFH – 2016-10-25T13:59:20.247