Centos source configuration and yum use

At present, the commonly used source websites in China are:

Introduce two source configurations: wget to obtain configuration, and manual/command to modify configuration. And yum use.

1. Alibaba source configuration (wgt mode)

  1. Make a backup copy first to prevent problems and then roll back.
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
  1. Download a copy of the latest source configuration file from the Ali website (download
    with wget command ) (Note: To use wget command, DNS must be configured, and you can access the Internet to support wget fetching information)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

At this time, viewing the contents of the /etc/yum.repos.d/CentOS-Base.repo file will be configured as Alibaba source.

Of course, you can also manually change the link in CentOS-Base.repo and replace it with
http://mirrors.aliyun.com (it is recommended to download with wget, manual errors may occur)

2. Tsinghua source configuration (command mode)

Enter the Huaqingyuan website: https://mirrors.cnnic.cn/ and
click on the following question mark of centos to enter the help:
Insert picture description here

Enter the help, the description tells you how to configure Tsinghua source files, the specific steps are as follows.
Insert picture description here
The above operations are replaced with commands as follows, which can automatically complete the replacement of repo source files.

sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
         -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
         -i.bak \
         /etc/yum.repos.d/CentOS-*.repo

Three, 163 source configuration

The source configuration method of 163 can use the above command, replace the source URL with: http://mirrors.163.com, or use wget to directly obtain the repo source file, the command is as follows:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

After the source is configured, you can use yum at will and download the installation package online.

Four, yum use

This command is mainly used in centos and rehad systems. Yum is an online package installation method, which relies on the above configuration source, and will obtain package information from the system configuration source and install it. After configuring the source, it is best to execute yum makecache to generate a local cache to facilitate subsequent search and installation efficiency.

Several commonly used yum commands in daily life are as follows:

    yum makecache 把服务器的包信息下载到本地电脑缓存起来。用yum -C 形式运行会更快提高搜索安装软件的速度(从缓存运行)
	yum search xxx和yum -C search subversion  搜索
	yum search 软件包 搜索软件包
	yum install 软件包 安装软件包
	yum remove 软件包
	yum update 更新系统
	yum upgrade package1 升级指定程序包package1
	yum list 显示所有已经安装和可以安装的程序包

More commands are explained as follows:

1 安装
yum install 全部安装
yum install package1 安装指定的安装包package1
yum groupinsall group1 安装程序组group1

2 更新和升级
yum update 全部更新
yum update package1 更新指定程序包package1
yum check-update 检查可更新的程序
yum upgrade package1 升级指定程序包package1
yum groupupdate group1 升级程序组group1

3 查找和显示
yum info package1 显示安装包信息package1
yum list 显示所有已经安装和可以安装的程序包
yum list package1 显示指定程序包安装情况package1
yum groupinfo group1 显示程序组group1信息yum search string 根据关键字string查找安装包

4 删除程序
yum remove | erase package1 删除程序包package1
yum groupremove group1 删除程序组group1
yum deplist package1 查看程序package1依赖情况

5 清除缓存
yum clean packages 清除缓存目录下的软件包
yum clean headers 清除缓存目录下的 headers
yum clean oldheaders 清除缓存目录下旧的 headers
yum clean, yum clean all (= yum clean packages; yum clean oldheaders) 清除缓存目录下的软件包及旧的headers

Guess you like

Origin blog.csdn.net/ludaoyi88/article/details/112298699