I have the following line my /etc/environment file:


I run this and get:

$ set|grep BROKER_URL

Then, I run:

$ sudo bash
# set|grep BROKER_URL

This is supposed to be a system wide environment variable. Why doesn't it show up in my sudo shell?

1 Answer 1


/etc/environment is a file used by PAM, meaning it is processed by a log in, which sudo bash does not do, and (from man sudoers):

Command environment

Since environment variables can influence program behavior, sudoers provides a means to restrict which variables from the user's environment are inherited by the command to be run. There are two distinct ways sudoers can deal with environment variables.

By default, the env_reset option is enabled. This causes commands to be executed with a new, minimal environment. On AIX (and Linux systems without PAM), the environment is initialized with the contents of the /etc/environment file.

Note that most GNU/linux systems do use PAM. You could try to get around this by using sudo -i, to use a login shell. However, this likely will still not work as "login shell" refers to how bash invokes itself, which does not include sourcing /etc/environment, and you are not actually logging in via PAM.

Your best bet is probably to configure sudo to do what you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .