Allowing user to set environment variable with sudo

Published on Author Akhil BansalLeave a comment

I encountered the following error today while installing a few packages on a ubuntu server using a sudo user.

“sudo: sorry, you are not allowed to set the following environment variables: DEBIAN_FRONTEND”

The command I ran was: “sudo DEBIAN_FRONTEND=noninteractive apt-get install -qy git-core”

I did search on google and did’nt find any direct answer for this error. Then I somehow figured out that if we change env_reset line in sudoers file then it allows sudo user to set environment.
I changed
“Defaults env_reset”
to
“Defaults !env_reset”

I don’t have any idea, what could be consequences of this change. So I reverted it after my job is done.

Leave a Reply

Your email address will not be published. Required fields are marked *