系统的字符集
# 查看字符集
locale
# 查看系统当前字符集
echo $LANG
# 查看系统是否安装中文字符集
locale -a |grep zh
# 安装中文字符集
yum -y groupinstall chinese-support
# 临时修改(当前终端生效):中文字符集
export LANG="zh_CN.UTF-8"
# 永久修改
echo "export LANG="zh_CN.UTF-8" >> /etc/proflile
source /etc/profile
# 查看
echo $LANG
文件的编码处理
# 用vim打开文件输入
:set fileencoding
# fileencoding后即为该文件编码格式
# 临时转换
:set fileencoding=utf-8
# 永久转换(先确认vimrc位置):
echo "set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936" >> /etc/vimrc
或
echo "set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936" >> ~/.vimrc
# file方式查看文件编码
file 文件名
或
file --mime-encoding 文件名