热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

centos7修改中文字符集Howtoavoidhavingto`exportLC_ALL=“zh_CN.UTF-8”`uponeachSSHconnection

EachtimeISSHtomyFedoraServer,thelocalesettingisnotright.$localelocale:Cannotset

Each time I SSH to my Fedora Server, the locale setting is not right.

$ locale

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: ??? LC_ALL ????????: ?????????
LC_CTYPE=UTF-8
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MOnETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHOnE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

And each time I would have to $ export LC_ALL="zh_CN.UTF-8" to make the desired language work.

But I have already set LANG=zh_CN.UTF-8 and LC_ALL=zh_CN.UTF-8 in /etc/locale.conf/ and in ~/.bashrc.

Is there any way I can make the export permanent? Really appreciate a lot!!

 

You are missing the export in your ~/.bashrc.

export LC_ALL=zh_CN.UTF-8

When you login to your user in the remote server via ssh, the ~/.bashrc of that user will get sourced and the locale will be set.

 

实例配置:

[root@zhiyi-first-server ~]# cat ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# added by Anaconda3 installer
export PATH="/root/anaconda3/bin:/root/datainfra/tool/alihbase-1.1.4/bin:$PATH"

# java
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre"
export LC_ALL=zh_CN.UTF-8

  

 


推荐阅读
author-avatar
日后再曰
这个家伙很懒,
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有