3

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.

5
  • 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 Commented Jul 14, 2014 at 8:43
  • Yes, you should recursive-grep the entire /etc directory. Under Debian, locales are set in /etc/default/locale.
    – vinc17
    Commented Jul 14, 2014 at 9:48
  • Thanks @vinc17. This file is indeed present; I've edited the question.
    – Sparhawk
    Commented Jul 14, 2014 at 10:33
  • Other possibilities are ~/.bash_profile and ~/.bash_login.
    – terdon
    Commented Jul 14, 2014 at 11:32
  • @terdon, these files don't exist on the Raspbian.
    – Sparhawk
    Commented Jul 14, 2014 at 12:19

1 Answer 1

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
1
  • 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
    Commented Jul 14, 2014 at 11:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.