How do sudo environment variables work in linux?

Deadly 提交于 2019-12-06 05:30:50

When you run sudo echo $MYVAR, the environment variable is expanded in your shell ... before the sudo command gets to see it.

When you run a script using sudo, that script only sees the environment variables that sudo has included in the environment. The default is to not to include them ... for security reasons.

The sudo command has an option -E that tells the command that the user wants to pass through all environment variables. The sudoers configuration file may or may not permit this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!