2

I've just installed Debian 8.6. I want to set http proxy environment variables for all users, so I edited /etc/environment following the guide on Debian's wiki. However, after rebooting, only root user's environment variables are set.

This is my /etc/environment content:

http_proxy=http://localhost:8123/
https_proxy=http://localhost:8123/
ftp_proxy=http://localhost:8123/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY=http://localhost:8123/
HTTPS_PROXY=http://localhost:8123/
FTP_PROXY=http://localhost:8123/
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"

And I check the result by:

echo $http_proxy

When logging in as root with sudo su, it gives me right result(http://localhost:8123/), but when using normal user the variables are not set. I also check all environment variables with env.

Update:

Here come more tests.

I add SET_BY_ETC_ENVIRONMENT="hello" to /etc/environment, export SET_BY_ETC_PROFILE="hello" to /etc/profile and export SET_BY_HOME_PROFILE="hello" to /home/perqin/.profile.

And here's the result:

user   | login via                    | SET_BY_ETC_ENVIRONMENT | SET_BY_ETC_PROFILE | SET_BY_HOME_PROFILE
-------|------------------------------|------------------------|--------------------|--------------------
perqin | GUI                          | no                     | no                 | no
root   | GUI                          | no                     | no                 | no
perqin | sudo su in terminal from GUI | yes                    | no                 | no
root   | su in terminal from GUI      | yes                    | no                 | no
perqin | ssh                          | yes                    | yes                | yes
root   | ssh                          | yes                    | yes                | no

So profile is only executed in ssh login. And NONE of them are applied in GUI! I am using Debian 8.6 with LXDE desktop environment.

Update 12.14

The output of grep pam_env /etc/pam.conf /etc/pam.d/* is as below:

/etc/pam.d/atd:auth required    pam_env.so
/etc/pam.d/cron:# Read environment variables from pam_env's default files, /etc/environment
/etc/pam.d/cron:# and /etc/security/pam_env.conf.
/etc/pam.d/cron:session       required   pam_env.so
/etc/pam.d/cron:session       required   pam_env.so envfile=/etc/default/locale
/etc/pam.d/lightdm:# Load environment from /etc/environment and ~/.pam_environment
/etc/pam.d/lightdm:auth      required pam_env.so envfile=/etc/default/locale
/etc/pam.d/lightdm-autologin:# Load environment from /etc/environment and ~/.pam_environment
/etc/pam.d/lightdm-autologin:auth      required pam_env.so envfile=/etc/default/locale
/etc/pam.d/lightdm-greeter:# Load environment from /etc/environment and ~/.pam_environment
/etc/pam.d/lightdm-greeter:auth      required pam_env.so envfile=/etc/default/locale
/etc/pam.d/login:# file /etc/security/pam_env.conf.
/etc/pam.d/login:session       required   pam_env.so readenv=1
/etc/pam.d/login:session       required   pam_env.so readenv=1 envfile=/etc/default/locale
/etc/pam.d/polkit-1:session       required   pam_env.so readenv=1 user_readenv=0
/etc/pam.d/polkit-1:session       required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
/etc/pam.d/sshd:# /etc/security/pam_env.conf.
/etc/pam.d/sshd:session    required     pam_env.so # [1]
/etc/pam.d/sshd:session    required     pam_env.so user_readenv=1 envfile=/etc/default/locale
/etc/pam.d/su:# file /etc/security/pam_env.conf.
/etc/pam.d/su:session       required   pam_env.so readenv=1
/etc/pam.d/su:session       required   pam_env.so readenv=1 envfile=/etc/default/locale

closed as too broad by Gilles, HalosGhost, don_crissti, Jeff Schaller, Eric Renouf Dec 13 '16 at 0:37

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • @RuiFRibeiro I also tried adding export lines in /etc/profile, but I still can't get the environment variables set. – Perqin Dec 12 '16 at 15:44
  • Are your users using the default bash shell? – Rui F Ribeiro Dec 12 '16 at 16:04
  • @RuiFRibeiro Yes. Running echo $SHELL gives me /bin/bash. – Perqin Dec 12 '16 at 16:08
  • @RuiFRibeiro I even add them to ~/. profile but also fails. Source the file manually does set the variables so it should not be the mistakes of the script... – Perqin Dec 12 '16 at 17:49