2

I've had a few issues with environmental variables not set correctly in my Raspbmc Raspberry Pi. Specifically, I've had to manually specify the following in ~/.bashrc.

export LANG='en_AU.UTF-8"
export LANGUAGE='en_AU:en'
export MAIL='/var/mail/pi'

However, in another Pi running vanilla Raspbian, these environmental variables are set correctly. I wanted to see what file specified these, but couldn't find it. I tested the files that I know of that run when logging in to a terminal. These gave no hits.

grep LANG -r /etc/profile /etc/profile.d/ /etc/bash.bashrc ~/.profile ~/.bashrc /etc/environment
grep MAIL -r /etc/profile /etc/profile.d/ /etc/bash.bashrc ~/.profile ~/.bashrc /etc/environment

Conversely, on my laptop running Arch, /etc/profile.d/locale.sh appears to set LANG, and ~/.profile specifies LANGUAGE. However, I could find no mention of MAIL.

How can I find where these environmental variables are set?


EDIT

I searched the whole of /etc and ~ for these strings in the working system (Raspbian).

grep "\bMAIL=" -r /etc 2>/dev/null
grep "\bMAIL=" -r ~ 2>/dev/null

Searching for MAIL gave no hits.

grep "\bLANG=" -r /etc 2>/dev/null
grep "\bLANG=" -r ~ 2>/dev/null

This strategy gave only a few hits for LANG in /etc, and none for LANGUAGE. There were a few false hits in /etc with LANG=C, and one true hit (as mentioned by vinc17) at /etc/default/locale:LANG=en_AU.UTF-8. However (as per a previous question by me), this file at /etc/default/locale is not sourced on my Raspbmc machine, so I presume that the situation is a bit more complicated than the mere presence of this file.

  • How about doing a recursive content search in the entire /etc, home, and other probable directories? grep "\bLANG=" -r /etc 2>/dev/null or find /etc -type f -exec grep "\bLANG=" {} + 2>/dev/null – Oleg Jul 14 '14 at 8:43
  • Yes, you should recursive-grep the entire /etc directory. Under Debian, locales are set in /etc/default/locale. – vinc17 Jul 14 '14 at 9:48
  • Thanks @vinc17. This file is indeed present; I've edited the question. – Sparhawk Jul 14 '14 at 10:33
  • Other possibilities are ~/.bash_profile and ~/.bash_login. – terdon Jul 14 '14 at 11:32
  • @terdon, these files don't exist on the Raspbian. – Sparhawk Jul 14 '14 at 12:19
2

And just to confuse things more, if you log on remotely using SSH your SSH client is to allowed to override (some of) the system defaults with your client side settings/preferences...

This is governed by the AcceptEnv directives in the sshd_config file e.g. :

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
  • Thanks again HBruijn. In the working Raspbian system, grep AcceptEnv /etc/ssh/sshd_config returns AcceptEnv LANG LC_*. On Raspbmc, locate sshd_config gives nothing. In Raspbian, I suppose the presence of LANG might explain this setting being inherited from the SSH client, but not LANGUAGE. Also, there is no mention of MAIL at all. – Sparhawk Jul 14 '14 at 11:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.