/etc/default/init LANG Setting Not Working

Hey guys,

I'm setting up a new server(Fujitsu M10-4 / Solaris 10 1/13) to move our app/DB and I'm having trouble figuring out why my LANG setting is not taking effect. I'm trying to set LANG=C in the /etc/default/init file which should make it the default system wide from what I gather. However it is always set to "en_US.UTF-8" when I log in. I've rebooted the server and removed/re-added the entry just to be sure, but no luck.

I can set the LANG setting to C in my shell manually, but it is not persistent when I switch over to bash or exit out. I've checked the /etc/profile, and the user profiles and I'm not finding anything that would be overriding the setting.

I suppose I can just set it in /etc/profile and the root profiles and call it a day, but I'd prefer to know exactly why the default init is not working for me. I'm hoping this is just something simple I'm missing. Anything to point me in the right direction would be appreciated.

Thanks

/etc/default/init contents:

#
# Copyright 1992, 1999-2002 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident  "@(#)init.dfl   1.7     02/12/03 SMI"
#
# This file is /etc/default/init.  /etc/TIMEZONE is a symlink to this file.
# This file looks like a shell script, but it is not.  To maintain
# compatibility with old versions of /etc/TIMEZONE, some shell constructs
# (i.e., export commands) are allowed in this file, but are ignored.
#
# Lines of this file should be of the form VAR=value, where VAR is one of
# TZ, LANG, CMASK, or any of the LC_* environment variables.  value may
# be enclosed in double quotes (") or single quotes (').
#
TZ=US/Eastern
CMASK=022
LANG=C

---------- Post updated at 11:23 AM ---------- Previous update was at 11:21 AM ----------

Here are the locale settings:

# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=
# locale -a
C
POSIX
en_CA
en_CA.ISO8859-1
en_CA.UTF-8
en_US
en_US.ISO8859-1
en_US.ISO8859-15
en_US.ISO8859-15@euro
en_US.UTF-8
es
es.UTF-8
es_MX
es_MX.ISO8859-1
es_MX.UTF-8
fr
fr.UTF-8
fr_CA
fr_CA.ISO8859-1
fr_CA.UTF-8
iso_8859_1

How do you log in?

If you want to change the default locale system-wide then in /etc/default/init:

 
 LANG=C
 LC_ALL=C
 

Also check the effect of any other LC_* variable(s) in that file.

1 Like

Mayhap the locale is (re-)set in the .profile (or equivalent) script on login?

1 Like

I'm logging in via SSH.

I already had LANG=C in the default init file, but I just added LC_ALL=C. After reboot, everything but LANG is set to C.

# locale
LANG=en_US.UTF-8
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=C
# echo $LANG
en_US.UTF-8

So it's pretty clear that LANG is getting set somewhere else, but I'm not finding where. I've logged in as root and my user account with the same results and have checked .profile, .bash_profile and /etc/profile.

Could there be another item I'm missing or is there a way to debug the login to see everything that is being executed on login?

---------- Post updated at 02:49 PM ---------- Previous update was at 01:44 PM ----------

I popped an "echo $LANG" into the /etc/profile and the local profile and it is getting set to en_US.UTF-8 before it gets to anything in those. Still digging.

Then, the LANG variable is set to en_US.UTF-8 on the client side and negotiated during the authentication. Use "ssh -v" to see it being passed.

You can set it to something else for your ssh session like this:

$ LANG=C LC_ALL=C ssh m10-4
1 Like

Note that if LC_ALL is set in your environment, none of the other locale environment variables ( LANG , LC_CTYPE , LC_NUMERIC , LC_TIME , LC_COLLATE , LC_MONETARY , and LC_MESSAGES ) can have any effect. LC_ALL overrides all of the other locale environment variables and should NEVER be set by the system as part of a user's login environment. Normally, a login environment should just provide a setting for LANG which provides a default value for all of the LC_* variables except LC_ALL .

Okay, so that pointed me in the right direction. My terminal is sending the en_US.UTF-8 LANG setting.

What was curious the same configuration didn't produce the same results on the old server. What I found was that the old server didn't have the en_US.UTF-8 locale installed. So the terminal was attempting to set it but it wasn't accepted on the other side and dropped to the C locale by default.

bash-3.2# locale -a
C
POSIX
en_CA
en_CA.ISO8859-1
en_CA.UTF-8
en_US
en_US.ISO8859-1
en_US.ISO8859-15
en_US.ISO8859-15@euro
es
es_MX
es_MX.ISO8859-1
es_MX.UTF-8
fr
fr_CA
fr_CA.ISO8859-1
fr_CA.UTF-8
iso_8859_1

The new server has the locale after installing the North America (nam) region from disk. Doesn't look like I can remove en_US.UTF-8 without removing the entire nam region according to localeadm. Had the same trouble when attempting to just install en_US. I had to install all of nam.

Guess I just need to override it in the profiles for the application. Thanks for your help guys.