How to change my commandline locale after CentOS decided to change it?

30,994

Solution 1

I just stumbled on this exact same problem, and found out why this is happens in my case and thought i'd share. I recently got a new iMac at work that runs OS X Lion (previous workstation was OS X Snow Leopard)

OS X Lion by default sets the locale in env variable LANG in Terminal. This was set to nl_NL.UTF-8. Sshd on the CentOS system imports this environment variable in its shell when you ssh into your CentOS box.

I solved it by disabling 'Set locale environment variables on startup' in Terminal preferences (settings->advanced)

Don't know if you run OS X on your desktop, but bottom line is: sshd on CentOS imports the locale settings from the ssh client workstation.

HTH

Solution 2

If you use SSH, there is another way to achieve the same result, which works in iTerm as well. You must modify the SSH configuration:

sudo vi /etc/ssh_config

Find and comment out the line containing

SendEnv LANG LC_*

Solution 3

If system-config-language doesn't help you, try this.

  1. Go to the CentOS system configuration directory

    $ cd /etc/sysconfig
    
  2. Make backup copy of your language setting file

    $ cp i18n i18n.backup
    
  3. Edit language setting file to allow English as default. You can edit the file by using nano or vim text editors available on all CentOS systems from SSH. I prefer vim, but nano is more easier:

    $ nano i18n
    
  4. Edit the file to include these lines as the first three lines of the file:

    $ LANG="en_US.UTF-8"
    $ SYSFONT="latarcyrheb-sun16"
    $ SUPPORTED="en_US.UTF-8:en_US:en"
    
  5. Save the file and restart system. If you can not restart the system you need to have permission to restart init.d

That should enable the new language setting. If you can not perform these through SSH because the access is too restricted, you will likely need to notify the ISP or whoever has physical access to the server.

Regards and best wishes.

Share:
30,994

Related videos on Youtube

Aron Rotteveel
Author by

Aron Rotteveel

Words describing me in third person.

Updated on September 18, 2022

Comments

  • Aron Rotteveel
    Aron Rotteveel over 1 year

    So apparently, CentOS decided I was Dutch, and thus, should not have a English locale.

    Apart from the fact that this greatly bothers me, I am having a pretty hard time actually changing it back. There does not seem to be a setlocale function, and system-config-language tells me I am using an English locale, even though my environment says otherwise.

    Any help would be appreciated.

    Output from locale:

    LANG=nl_NL.UTF-8
    LC_CTYPE="nl_NL.UTF-8"
    LC_NUMERIC="nl_NL.UTF-8"
    LC_TIME="nl_NL.UTF-8"
    LC_COLLATE="nl_NL.UTF-8"
    LC_MONETARY="nl_NL.UTF-8"
    LC_MESSAGES="nl_NL.UTF-8"
    LC_PAPER="nl_NL.UTF-8"
    LC_NAME="nl_NL.UTF-8"
    LC_ADDRESS="nl_NL.UTF-8"
    LC_TELEPHONE="nl_NL.UTF-8"
    LC_MEASUREMENT="nl_NL.UTF-8"
    LC_IDENTIFICATION="nl_NL.UTF-8"
    LC_ALL=
    

    Both my ~/.bashrc as ~/.bash_profile contain no locale settings. Additionally, /etc/bashrc does not contain any locale references either.

    • dreua
      dreua about 3 years
      Make sure LANGUAGE is not set (or set to your desired value). It is not listed by locale but still overrides all other language settings in command line software like vim and dnf.