sudo -E

If you even find yourself in a situation where you need to run a superuser command in your carefully crafted terminal state, use:

sudo -E

NAME
     sudo, sudoedit — execute a command as another user
[..]
-E, --preserve-env
                 Indicates to the security policy that the user wishes to preserve their existing environment
                 variables.  The security policy may return an error if the user does not have permission to pre‐
                 serve the environment.

My use case was running a build script that fetched all its dependencies from the internet. My proxy settings were configured for my own user, but not for the root user. This command saved me enourmous amounts of headaches.

tags:
blog comments powered by Disqus