Ubuntu – .pam_environment not loaded in TTY

15.04environment-variablespam-environmenttty

I have environment variables set in ~/.pam_environment and they exist as expected in any graphical terminal emulator I open. If I open a virtual terminal, e.g. TTY1, and login, my PAM environment variables are not present.

How can I ensure ~/.pam_environment variables are always loaded?

Best Answer

One way is to edit /etc/pam.d/login like this:

--- a/login 2015-06-15 03:35:17.422387358 +0200
+++ b/login 2015-06-15 03:36:41.535536201 +0200
@@ -50,7 +50,7 @@
 session       required   pam_env.so readenv=1
 # locale variables are also kept into /etc/default/locale in etch
 # reading this file *in addition to /etc/environment* does not hurt
-session       required   pam_env.so readenv=1 envfile=/etc/default/locale
+session       required   pam_env.so readenv=1 user_readenv=1 envfile=/etc/default/locale

 # Standard Un*x authentication.
 @include common-auth

Can't tell if it's 'the proper way', though.

Related Question