Interview Prep/Linux/Permissions, Users & sudo

How does sudo handle environment variables?

AdvancedConceptPermissions, Users & sudo
Answer

By default env_reset gives the command a minimal clean environment and secure_path replaces PATH. That is why sudo mytool can fail with "command not found" when the tool is in /usr/local/bin or your own PATH. Keep specific variables with Defaults env_keep += "http_proxy https_proxy", or pass them explicitly: sudo VAR=value cmd (if allowed) or sudo -E (preserve, if policy permits).

All Linux questions Roadmap: Linux

More on Permissions, Users & sudo