3

Using Ubuntu 14.04 LTS, I'm having a problem trying to read environment variables from /etc/environment when using sudo env. Basically, they are not being displayed. When I do just env, these variables appear like it should.

In my other server, which is running Ubuntu 13.04, both sudo env and env display variables from /etc/environment.

How do I get sudo env to read the environment variables set in /etc/environment in Ubuntu 14.04 LTS?

UPDATE - 2014-07-14

I checked /etc/pam.d/sudo, and they are exactly the same:-

#%PAM-1.0

auth       required   pam_env.so readenv=1 user_readenv=0
auth       required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
@include common-auth
@include common-account
@include common-session-noninteractive
  • 3
    /etc/environment is used by pam_env. Check /etc/pam.d on both hosts. I'm betting one of them is different. – Patrick Jul 11 '14 at 21:44
  • @Patrick, I updated my question above. Both files are the same, am I checking the wrong files here? Thanks. – limc Jul 14 '14 at 12:39
  • I am using Ubuntu 14.04 and sudo env works for me. It must be something other than distro version difference. – Oleg Jul 15 '14 at 0:29
  • Check with --login; that will help remove sudo settings that could be allowing existing environment variables through. I've confirmed the behaviour with --login and I suspect that this is a bug. – Curt J. Sampson Feb 27 '18 at 11:28

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.