LC_CTYPE: cannot change locale (UTF-8) error
来源:互联网 发布:ubuntu wifi 热点 编辑:程序博客网 时间:2024/05/22 12:51
If you’ve recently upgraded to CentOS 6.3 you might have seen the following error message after logging in to your system via SSH:
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
Although it’s easy to asume the problem must be on the server-side (and in a part it is), but you actually have to fix an ssh_config setting on your local system.
SSH sends LC_* environment variables
The problem is that your SSH client is by default configured to send your LC_* environment variables. This means that SSH will try to set every LC_* variable you have set on your local (connecting) system on the remove system as well. The problem is that since CentOS 6.3 the name of the locale is not compatible with what some SSH clients (like the default OpenSSH client on Apple Mac OSx) has set. Let’s take a closer look:
Locale setting on local system
When you run:
printenv
you see which LC_* variables are set locally. On my Mac OSx Mountain Lion system it prints:
LC_TYPE=UTF-8
Locales available on the remote CentOS system
If you enter:
locale -a
you get a list of locales which you have available on your CentOS system. The locale you have set on your local system (“UTF-8″ in my case) should also be present here. When grep’ing the list:
locale -a | grep ”UTF-8″
it quickly becomes clear that my the locale setting on my locale (Mac OSx) system is not available on the remote CentOS system.
Preventing OpenSSH from sending the LC_* variables
The fix is very easy. On your local system open your ssh_config file as root (usually in /etc/ssh_config or /etc/sshd/ssh_config) and comment this line:
SendEnv LANG LC_*
That’s it! From now on you will no longer get the annoying Bash error. Alternatively you can also set the locale setting of your locale system to something that matches your remote system, but this is the foolproof way that will always work, regardless of the locale config of your local and remote system.
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
Although it’s easy to asume the problem must be on the server-side (and in a part it is), but you actually have to fix an ssh_config setting on your local system.
SSH sends LC_* environment variables
The problem is that your SSH client is by default configured to send your LC_* environment variables. This means that SSH will try to set every LC_* variable you have set on your local (connecting) system on the remove system as well. The problem is that since CentOS 6.3 the name of the locale is not compatible with what some SSH clients (like the default OpenSSH client on Apple Mac OSx) has set. Let’s take a closer look:
Locale setting on local system
When you run:
printenv
you see which LC_* variables are set locally. On my Mac OSx Mountain Lion system it prints:
LC_TYPE=UTF-8
Locales available on the remote CentOS system
If you enter:
locale -a
you get a list of locales which you have available on your CentOS system. The locale you have set on your local system (“UTF-8″ in my case) should also be present here. When grep’ing the list:
locale -a | grep ”UTF-8″
it quickly becomes clear that my the locale setting on my locale (Mac OSx) system is not available on the remote CentOS system.
Preventing OpenSSH from sending the LC_* variables
The fix is very easy. On your local system open your ssh_config file as root (usually in /etc/ssh_config or /etc/sshd/ssh_config) and comment this line:
SendEnv LANG LC_*
That’s it! From now on you will no longer get the annoying Bash error. Alternatively you can also set the locale setting of your locale system to something that matches your remote system, but this is the foolproof way that will always work, regardless of the locale config of your local and remote system.
0 0
- LC_CTYPE: cannot change locale (UTF-8) error
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (EN_US.UTF-8)
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
- warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8)
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8)
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8)
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (EN_US.UTF-8)
- How to fix warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
- Centos7 -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
- bug宝典linux篇 LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
- Linux之——bash: warning: setlocale: LC_CTYPE: cannot change locale (EN_US.UTF-8)
- bash: warning: setlocale: LC_CTYPE: cannot change locale
- warning: setlocale: LC_CTYPE: cannot change locale
- warning: setlocale: LC_CTYPE: cannot change locale (en_US.utf8)
- svn "cannot set LC_CTYPE locale"
- warning: setlocale: LC_CTYPE: cannot change locale (en_US): No such file or directory
- bash自动补全时出现“-bash: warning: setlocale: LC_CTYPE: cannot change locale”的解决方法
- warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
- IoC模式
- 交互设计的KISS原则
- 原码,补码,反码,移码
- 非常值得学习和借鉴的电商项目shop++
- C++使用ADO存取图片
- LC_CTYPE: cannot change locale (UTF-8) error
- Ubuntu 使用VI
- 程序员求职面试心经40条——谨记原则
- IOS 模糊掉图片指定区域
- 算法实验二:实习和工作
- 【剑指offer】面试题4替换空格
- cocos3.1.1+vs2012+cocosstudio
- 移动云服务平台 推送工具 OpenMobster
- idea+tomcat+tomcat运行项目(一)