Fw: about the "locale" command

Bob Proulx bob at proulx.com
Fri Oct 26 06:35:43 EST 2007


Davide Cosentino wrote:
> ssh -p 22 root at host1 locale
> LANG=en_US.UTF-8
> LC_CTYPE="en_US.UTF-8"
> ...

Notice that LANG is reported without quotes while the others are
reported with quotes?  This is a hint.  When a variable is set the
locale command does not report it with quotes.  When the variable is
inferred by the presence of a set variable then it is quoted.  So here
I can see that LANG is set to en_US.UTF-8.

> On the opposite I get:
> 
> LANG=
> LC_CTYPE="POSIX"

Here I can see that LANG is not set.

> The question is: why is this difference and how can I fix host2 in order to
> produce the "correct" locale output (i.e.: to produce the same locale as
> when I run from locally)?

I suspect that in the host1 ~root/.bashrc file that LANG is
explicitly set to LANG=en_US.UTF-8 and on the other host that it is
not.  The bash shell tries to guess when it is being run by a remote
shell non-interactively and sources ~/.bashrc in that case.

Depending on how sshd is installed and configured on your system it
may be setting LANG through /etc/environment or /etc/default/locale or
/etc/default/ssh or other system specific location.  It is usually
installed with PAM and therefore PAM configuration applies too.

Bob


More information about the openssh-unix-dev mailing list