跳至主要內容

CentOS

程序员李某某大约 2 分钟

CentOS

更改yum源

## 备份
cp -r /etc/yum.repos.d /etc/yum.repos.d.bak

cd /etc/yum.repos.d/
vi CentOS-Base.repo ## 创建文件,加入相关配置
## =================
## 清除系统所有的yum缓存
yum clean all
## 生成新的yum缓存
yum makecache
## 更新源
yum repolist
  • 添加相关配置

    # CentOS-Base.repo
    #
    # The mirror system uses the connecting IP address of the client and the
    # update status of each mirror to pick mirrors that are updated to and
    # geographically close to the client.  You should use this for CentOS updates
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you can try the 
    # remarked out baseurl= line instead.
    #
    #
    
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #released updates 
    [updates]
    name=CentOS-$releasever - Updates
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
    #$baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever - Plus
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    

    阿里

    [base]
    name=CentOS-$releasever - Base - 阿里云
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
    gpgcheck=0
    enabled=1
    
    [updates]
    name=CentOS-$releasever - Updates - 阿里云
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
    gpgcheck=0
    enabled=1
    
    # 可根据需要添加其他仓库如 epel 等
    

恢复出厂设置

字符集

查看

第一种:

echo $LANG
###########
zh_CN.UTF-8

第二种:

env |grep LANG
############
LANG=zh_CN.UTF-8

第三种:

export |grep LANG
#############
declare -x LANG="zh_CN.UTF-8"

第四种:

locale

###########
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.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=

修改

方法一:直接设置变量的方式修改

export LANG=zh_CN.UTF-8

方法二:

vim /etc/sysconfig/i18n
#######
LANG="zh_CN.UTF-8"
#######
source /etc/sysconfig/i18n 

CentOS7 xshell 连接系统显示中文乱码解决

## 临时
export LANG=zh_CN.gbk
## 永久
vim /etc/profile
########## 在文件最后添加
export LANG=zh_CN.gbk  
##########
source /etc/profile
上次编辑于:
贡献者: 李元昊,liyuanhao