linux 服务器的语言,详解如何一键设置Linux服务器终端显示语言为中文-服务器设置...

概述

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

34423b6244d324e9610652300e3a1696.pngDebian 8 / 9

Ubuntu 14 / 16

CentOS 6 / 7

1、脚本内容

注意需要联网才可以。#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

export PATH

# Check System Release

if [ -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 dependencies

if [ "${release}" == "centos" ]; then

\tyum -y install wget ca-certificates locales localedef

else

\tapt-get update

\tapt-get -y install wget ca-certificates locales

fi

# Get Word dir

dir=$(pwd)

# Change Locale

if [ "${release}" == "centos" ]; then

\tlocaledef -v -c -i zh_CN -f UTF-8 zh_CN.UTF-8 > /dev/null 2>&1

\tcd /etc

\trm -rf locale.conf

\twget https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/locale.conf > /dev/null 2>&1

\tcp locale.conf locale

\tcat locale.conf >> /etc/environment

elif [ "${release}" == "debian" ]; then

\trm -rf /etc/locale.gen

\trm -rf /etc/default/locale

\trm -rf /etc/default/locale.conf

\tcd /etc/

\twget https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/locale.gen > /dev/null 2>&1

\tlocale-gen

\tcd /etc/default/

\twget https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/locale.conf > /dev/null 2>&1

\tcp locale.conf locale

elif [ "${release}" == "ubuntu" ]; then

\t\trm -rf /etc/locale.gen

\trm -rf /etc/default/locale

\trm -rf /etc/default/locale.conf

\tcd /etc/

\twget https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/locale.gen > /dev/null 2>&1

\tlocale-gen

\tcd /etc/default/

\twget https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/locale.conf > /dev/null 2>&1

\tcp locale.conf locale

fi

# Echo Success

clear

echo "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 self

cd ${dir}

rm -rf LocaleCN.sh

b8dafaa542da33b8bb5ccaf8dd757eda.png

2f6d151fcbd4e5124d19c8a4a98e8d10.png

3、执行结果:

d378137658337c77d402cfb0b3904b65.png

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

842629b2115aca2e4542596cd6449472.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值