Ubuntu – Why doesn’t the environment variable get set

eclipseenvironment-variablesUbuntu

I have to set an environment variable called GDK_NATIVE_WINDOWS to fix the problem with Eclipse buttons in Ubuntu. To set the environment variable, I added the following line to ~/.pam_environment.

GDK_NATIVE_WINDOWS DEFAULT=true

Surprisingly, the environment variable doesn't get set when I echo $GDK_NATIVE_WINDOWS in a terminal. However, all other environment variables that I've listed in ~/.pam_environment are set properly. Besides, when I switch to a tty, e.g. Alt+Ctrl+F1, the environment variable gets set correctly. What's wrong with setting this environment variable in ~/.pam_environment?

Best Answer

Stick to the simple "key=value" syntax in the ~/.pam_environment file. No DEFAULT, OVERRIDE, ${HOME}, no nothing. Just key=value. The man page you linked to is for pam_env.conf, only. See "man 8 pam_env" which does not promise anything else "This module can also parse a file with simple KEY=VAL pairs on separate lines.".

By the way putting something like PATH=${PATH}:more/paths in ./pam_environment is a great way to break almost any attempt to login, since the PATH gets set to ${PATH}:more/paths literally (not much to be found there). To rescue, "/bin/mv .pam_environment out_of_the_way" and re-login.