How to keep environment variables when using sudo

前端 未结 6 743
滥情空心
滥情空心 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:31

    For individual variables you want to make available on a one off basis you can make it part of the command.

    sudo http_proxy=$http_proxy wget "http://stackoverflow.com"
    

提交回复
热议问题