Yum(Yellow dog Updater Modified) 包管理器
Yum工作时需要依赖rpm 软件管理器来完成工作,Yum 配置信息都存放在一个名为 yum.repos.d 的配置文件中,位于/etc/yum.repos.d 目录下,系统安装完毕后,此目录下会自动生成有yum的网络源
1、Yum查询
格式:yum 选项 查询工作项目
选项:-y yes
参数:
search:搜索某个软件名称或者描述的关键字
list : 列出yum管理的所有软件名称和版本 类似 rpm -qa
info:列出yum管理的所有软件名称和版本 类似 rpm -qai
provides : 从文件中取搜索软件 类似 rpm -qf
实例:搜索raid相关软件
[root@VM-4-2-centos Python-3.8.3]# yum search raid Loaded plugins: fastestmirror, langpacks Determining fastest mirrors =================================== N/S matched: raid =================================== dmraid.i686 : dmraid (Device-mapper RAID tool and library) dmraid.x86_64 : dmraid (Device-mapper RAID tool and library) dmraid-devel.x86_64 : Development libraries and headers for dmraid. dmraid-events-logwatch.x86_64 : dmraid logwatch-based email reporting libblockdev-mdraid.i686 : The MD RAID plugin for the libblockdev library libblockdev-mdraid.x86_64 : The MD RAID plugin for the libblockdev library libblockdev-mdraid-devel.i686 : Development files for the libblockdev-mdraid : plugin/library libblockdev-mdraid-devel.x86_64 : Development files for the libblockdev-mdraid : plugin/library libbraiding.x86_64 : Library for computations on braid groups libbraiding-devel.x86_64 : Development files for libbraiding libstoragemgmt-megaraid-plugin.noarch : Files for LSI MegaRAID support for libstoragemgmt dmraid-events.x86_64 : dmevent_tool (Device-mapper event tool) and DSO iprutils.x86_64 : Utilities for the IBM Power Linux RAID adapters mdadm.x86_64 : The mdadm program controls Linux md devices (software RAID arrays) snapraid.x86_64 : Disk array backup for many large rarely-changed files Name and summary matches only, use "search all" for everything.
实例:列出yum服务器 所有软件
# yum list
实例:列出服务器上所有可以升级的软件
# yum list updates
实例:列出提供passwd文件的软件有哪些
[root@VM-4-2-centos Python-3.8.3]# yum provides passwd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile passwd-0.79-6.el7.x86_64 : An utility for setting or changing passwords using PAM Repo : os passwd-0.79-6.el7.x86_64 : An utility for setting or changing passwords using PAM Repo : @os
2、yum安装/升级
格式:yum install | update 参数
参数:
install 后面接安装的软件
update 后面接要升级的软件 不带软件名字则升级整个系统的软件
实例:安装abrt-addon-ccpp
# yum install abrt-addon-ccpp
3、yum删除
格式:yum remove 删除
实例:删除软件abrt-addon-ccpp
# yum remove abrt-addon-ccpp
4、yum 清除缓存
格式:yum clean 选项 参数
选项:
packages清除缓存目录下的软件包
headers清除缓存目录下的headers
oldheaders清除缓存目录下的旧的headers
5、yum配置文件
(如果下载不稳定,可以修改该配置)
# vi /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base [extras] gpgcheck=1 gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7 enabled=1 baseurl=http://mirrors.tencentyun.com/centos/$releasever/extras/$basearch/ name=Qcloud centos extras - $basearch [os] gpgcheck=1 gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7 enabled=1 baseurl=http://mirrors.tencentyun.com/centos/$releasever/os/$basearch/ name=Qcloud centos os - $basearch [updates] gpgcheck=1 gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7 enabled=1 baseurl=http://mirrors.tencentyun.com/centos/$releasever/updates/$basearch/ name=Qcloud centos updates - $basearch
[base] 容器名字
name 容器意义
mirrorlist= 列出容器可以使用的映射站台,如果不想使用,可以注释掉这
baseurl= 重要 容器实际网址
enable=1 让容器启动,如果关闭改为0
gpgcheck=1 指定是否需要查阅RPM文件内的数字签章
gpgkey= 数字签章公钥文件所在位置 一般默认
修改完毕后,清除缓存
# yum clean all
重新生成缓存列表
# yum list
查看当前所使用的所有容器
# yum repolist all [root@VM-4-2-centos Python-3.8.3]# yum repolist all Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile repo id repo name status !epel/7/x86_64 EPEL for redhat/centos 7 - x86_64 enabled: 13,753 !extras/7/x86_64 Qcloud centos extras - x86_64 enabled: 518 !os/7/x86_64 Qcloud centos os - x86_64 enabled: 10,072 !updates/7/x86_64 Qcloud centos updates - x86_64 enabled: 5,061 repolist: 29,404
6、yum优点与缺点
优点:方便快捷,不用考虑依赖包
缺点:无法人工干预,安装版本较低
7、验证YUM
安装http服务
# yum -y install httpd
语法:
yum [options] [command] [package]
options 可选参数
-h 帮助参数
-y 确认参数
-q 静默安装参数
command 需要进行的操作
package 软件包或组
8、yum安装软件
安装xxx包 yum install PACKAGE #yum install httpd
9、升级操作
更新系统中所有需要更新的包 yum update 更新某个软件包 yum update package # yum update httpd
10、检查当前系统中需要更新的包
yum check-update
11、查找操作
显示软件源中所有可用的包 yum list 显示系统中已经安装过的包 yum list installed 显示某个包的信息 yum info PACKAGE #yum info httpd
12、删除操作
删除某个包 yum remove PACKAGE # yum remove httpd
13、清除缓存
yum clean all