Using /etc/environment.d/*.conf to set global environment for all users

Is /etc/environment.d/*.conf a valid place to put environment config on Ubuntu 18.04 for all users?

I've tried a file with the following contents:

BRAD_TEST=true

However, after logging in and running env, this variable does not appear to be set in the environment. Even after a reboot, it wasn't there.

Two questions:

  • Is this feature of systemd enabled in Ubuntu 18.04?
  • Does this feature allow setting environment for all users, or is it intended for another purpose?
9

1 Answer

Ok after rebooting my system today I got it to work but I followed the recommended naming style for such files and this 60-foo.conf is the name I gave to the file and I also had to create that folder and it was called environment.d and of course it was placed in the /etc folder.

This is the content of that file:

FOO_DEBUG=force-software-gl,log-verbose

After the reboot doing echo $FOO_DEBUG produced the contents of that file:

force-software-gl,log-verbose

Note several things here:

  • Filename follows convention as found in the man pages
8

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like