How to keep environment variables when using sudo

前端 未结 6 742
滥情空心
滥情空心 2020-11-22 01:55

When I use any command with sudo the environment variables are not there. For example after setting HTTP_PROXY the command wget works fine without sudo

6条回答
  •  灰色年华
    2020-11-22 02:42

    You can also combine the two env_keep statements in Ahmed Aswani's answer into a single statement like this:

    Defaults env_keep += "http_proxy https_proxy"

    You should also consider specifying env_keep for only a single command like this:

    Defaults!/bin/[your_command] env_keep += "http_proxy https_proxy"

提交回复
热议问题