龙空技术网

分享一个linux实用脚本--一键设置Linux服务器终端显示语言为中文

波波说运维 2955

前言:

当前同学们对“centos6中文语言包”大约比较讲究,姐妹们都需要分析一些“centos6中文语言包”的相关文章。那么小编在网上搜集了一些关于“centos6中文语言包””的相关文章,希望同学们能喜欢,大家快快来了解一下吧!

概述

分享一个简单的脚本,可以实现linux服务器一键设置语言为中文,支持以下系统:

Debian 8 / 9Ubuntu 14 / 16CentOS 6 / 7
1、脚本内容

注意需要联网才可以。

#!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbinexport PATH# Check System Releaseif [ -f /etc/redhat-release ]; then release="centos"elif cat /etc/issue | grep -Eqi "debian"; then release="debian"elif cat /etc/issue | grep -Eqi "ubuntu"; then release="ubuntu"elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then release="centos"elif cat /proc/version | grep -Eqi "debian"; then release="debian"elif cat /proc/version | grep -Eqi "ubuntu"; then release="ubuntu"elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then release="centos"fi# Check root[[ $EUID -ne 0 ]] && echo -e "${RED}Error:${PLAIN} This script must be run as root!" && exit 1# Install some dependenciesif [ "${release}" == "centos" ]; then	yum -y install wget ca-certificates locales localedef else	apt-get update 	apt-get -y install wget ca-certificates locales fi# Get Word dirdir=$(pwd)# Change Localeif [ "${release}" == "centos" ]; then	localedef -v -c -i zh_CN -f UTF-8 zh_CN.UTF-8 > /dev/null 2>&1	cd /etc	rm -rf locale.conf	wget  > /dev/null 2>&1	cp locale.conf locale	cat locale.conf >> /etc/environmentelif [ "${release}" == "debian" ]; then	rm -rf /etc/locale.gen	rm -rf /etc/default/locale	rm -rf /etc/default/locale.conf	cd /etc/	wget  > /dev/null 2>&1	locale-gen	cd /etc/default/	wget  > /dev/null 2>&1	cp locale.conf localeelif [ "${release}" == "ubuntu" ]; then		rm -rf /etc/locale.gen	rm -rf /etc/default/locale	rm -rf /etc/default/locale.conf	cd /etc/	wget  > /dev/null 2>&1	locale-gen	cd /etc/default/	wget  > /dev/null 2>&1	cp locale.conf localefi# Echo Successclearecho "Your Machine Language setting is changed to Chinese(Simplified)"echo "Reconnect to your machine to check it"echo ""echo "copyright by hwb"echo "QQ : 1275758000"# Delete selfcd ${dir}rm -rf LocaleCN.sh
3、执行结果:

觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~

标签: #centos6中文语言包