一、查看本机已安装的软件,使用Yum list 加上 installed。若不加installed,将会列出所有源的所有软件。
若不确定名称,可加上 < | grep 软件名> 查找所有类似软件。

[root@learncloud ~]# yum list installed  #需加上installed过滤条件
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
GeoIP.x86_64                          1.5.0-14.el7                      @os      
NetworkManager.x86_64                 1:1.18.0-5.el7_7.1                @updates 
NetworkManager-libnm.x86_64           1:1.18.0-5.el7_7.1                @updates
...

[root@learncloud ~]# yum list installed | grep device #通过grep根据关键字过滤
device-mapper.x86_64                    7:1.02.158-2.el7_7.2           @updates 
device-mapper-event.x86_64              7:1.02.158-2.el7_7.2           @updates

二、查看指定软件信息,可以查看是否已安装、版本、所在源、依赖等。
使用:Yum info <软件名> 命令,再加上指定软件名称。若不加上软件名,将列出所有软件。
若不确定名称,可加上 < | grep 软件名> 查找所有类似软件。

[root@learncloud ~]# yum info docker   #查询指定软件的相关信息
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages               #可安装,也就是此软件未安装到本机
Name        : docker
Arch        : x86_64
Epoch       : 2
Version     : 1.13.1
Release     : 109.gitcccb291.el7.centos
Size        : 18 M
Repo        : extras/7/x86_64
Summary     : Automates deployment of containerized applications
URL         : https://github.com/docker/docker
License     : ASL 2.0
Description : Docker is an open-source engine that automates the deployment of any
            : application as a lightweight, portable, self-sufficient container that will
            : run virtually anywhere.
            : 
            : Docker containers can encapsulate any payload, and will run consistently on
            : and between virtually any server. The same container that a developer builds
            : and tests on a laptop will run at scale, in production*, on VMs, bare-metal
            : servers, OpenStack clusters, public instances, or combinations of the above.

[root@learncloud ~]# yum info | grep docker         #通过grep来过滤指定关键字
            :  - docker       Docker container
Name        : cockpit-docker
Name        : docker
URL         : https://github.com/docker/docker
Name        : docker-client
URL         : https://github.com/docker/docker
Name        : docker-client-latest
URL         : https://github.com/projectatomic/docker
Name        : docker-common
Summary     : Common files for docker and docker-latest
URL         : https://github.com/docker/docker
Description : This package contains the common files /usr/bin/docker which will
            : point to /usr/bin/docker-current or /usr/bin/docker-latest
            : configurable via /etc/sysconfig/docker

三、设置新的yum源,可通过yum-config-manager命令进行添加,或者复制repo文件到/etc/yum.repo.d 目录下,清除缓存后即可使用

[root@learncloud yum.repos.d]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo   #使用yum-config-manager命令,--add-repo参数添加
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo   #显示添加成功

[root@learncloud yum.repos.d]# ll
total 12
-rw-r--r-- 1 root root  614 Apr 15 17:01 CentOS-Base.repo
-rw-r--r-- 1 root root  230 Apr 15 17:01 CentOS-Epel.repo
-rw-r--r-- 1 root root 2424 Oct 19  2019 docker-ce.repo   #新增的源

四、安装软件,使用yum install 软件名,加上-y参数可以自动回答Yes交互确认步骤。

[root@learncloud ~]# yum install -y docker
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
........  #中间的输出省略                                                  

Complete!  #出现Complete提示,即完成安装
[root@learncloud ~]#