Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I logged in to Ubuntu 12.04 desktop via ssh, the env variables of locale had been set are followed:
env | grep LC


so my question is:

where set such env, and why LC_CTYPE and LC_MESSAGES NOT set?

share|improve this question
This question appears to be off-topic because it is speculative in nature – bodhi.zazen Dec 18 '13 at 16:52
@bodhi.zazen: I really don't understand what you mean by "speculative in nature". To me they are questions about how Ubuntu works. – Gunnar Hjalmarsson Dec 19 '13 at 14:02
I suppose your question seemed ambiguous, I could not tell if you were ashing how to set environmental variables and/or speculate why the developers choose to set some and not other variables. – bodhi.zazen Dec 19 '13 at 14:12
@bodhi.zazen: There is nothing about LC_* or LANG in file /etc/environment and there is only one line: LANG=zh_CN.UTF-8 in /etc/default/locale. But when log in Ubuntu 12.04 desktop, I found LC_* but LC_MESSAGES, LC_CTYPE and LC_COLLATE were set zh_CN.UTF-8. So I confused with that! And Gunnar Hjalmarsson's answer help me! – sfz Dec 19 '13 at 15:36
up vote 0 down vote accepted

When you use Language Support to set language and regional formats, the resulting environment variables are written to ~/.pam_environment, as you already have found out. When you apply system-wide, the variables are written to /etc/default/locale.

The reason why LC_MESSAGES, LC_CTYPE and LC_COLLATE are not set explicitly is that LANG is set, and the locale name in LANG is inherited by those three LC_* variables. You can check that by running the locale command instead of env | grep LC.

share|improve this answer
Yes, locale command can list all LC_* variables; but why LC_MESSAGES, LC_CTYPE and LC_COLLATE are NOT set in ~/.pam_environment? – sfz Dec 19 '13 at 7:05
Didn't I cover that in my answer? Because LANG is set, and LC_MESSAGES, LC_CTYPE and LC_COLLATE inherit the LANG value, which is good since they should have the same value as LANG. In other words there is no need to set them explicitly in ~/.pam_environment. – Gunnar Hjalmarsson Dec 19 '13 at 9:29
Thank you for your patient. I really really understand. – sfz Dec 19 '13 at 12:37

System wide environmental variables are set in /etc/environment and, for locales /etc/default/locale

/etc/environment - This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide path settings.

/etc/default/locale - This file is specifically meant for system-wide locale (LC_*) environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line.

For additional information, see and

As to "why LC_CTYPE and LC_MESSAGES NOT set?", I could not find a discussion, I suggest you might have better luck filing a bug report, feature request, or perhaps IRC. That part of your question may be considered off topic and speculative.

share|improve this answer
in /etc/environment there are nothing about LC_* and only one line: LANG=zh_CN.UTF-8 in /etc/default/locale – sfz Dec 18 '13 at 17:00
I found the such env variables defined in $HOME/.pam_environment. thx very much! – sfz Dec 18 '13 at 17:09
OK, glad you got it sorted =) – bodhi.zazen Dec 18 '13 at 17:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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