-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
来源:互联网 发布:工程宝软件下载 编辑:程序博客网 时间:2024/05/02 04:32
Fixing the LC_CTYPE: cannot change locale (UTF-8) error on CentOS
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 (EN_US.UTF-8)
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (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)
- bash: warning: setlocale: LC_CTYPE: cannot change locale
- warning: setlocale: LC_CTYPE: cannot change locale (zh_CN.UTF-8)
- Centos7 -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
- Linux之——bash: warning: setlocale: LC_CTYPE: cannot change locale (EN_US.UTF-8)
- warning: setlocale: LC_CTYPE: cannot change locale
- How to fix warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
- bash自动补全时出现“-bash: warning: setlocale: LC_CTYPE: cannot change locale”的解决方法
- warning: setlocale: LC_CTYPE: cannot change locale (en_US.utf8)
- LC_CTYPE: cannot change locale (UTF-8) error
- warning: setlocale: LC_CTYPE: cannot change locale (en_US): No such file or directory
- warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
- bug宝典linux篇 LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
- svn: warning: cannot set LC_CTYPE locale 解决方法
- 菜鸟学PureMVC记
- const用法
- 用汇编的眼光看C++
- 1.2 初窥输入输出
- C++语言概述
- -bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
- 25个必须记住的SSH命令
- 题目1127:简单密码
- 使用lock_sga和pre_page_sga参数保证SGA常驻物理内存
- 自增运算符在gcc和vc下的不同结果
- nufront平台添加RTC时钟芯片ds1307
- 控 制 器
- glusterFS: self-heal 的触发条件
- 异步加载图片