一、简介
yum( Yellow dog Updater, Modified)是一个在 Fedora 和 RedHat 以及 SUSE 中的 Shell 前端软件包管理器。基于 RPM 包管理,能够从指定的服务器自动下载 RPM 包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

二、语法
yum [options] command [package …]
  [options] 可选项
  command 命令
  [packages…] 包名,可以有多个

三、常用命令
1、安装:yum install PACKAGE_NAME…
2、更新:
  升级:yum update PACKAGE_NAME…
  降级:yum downgrade PACKAGE_NAME…
3、卸载:
  yum remove PACKAGE_NAME…
  yum erase PACKAGE_NAME…
4、查看:
  显示yum仓库列表:yum repolist [all|enabled|disabled]
  显示所有可安装的软件清单:yum list
  显示:yum list {available|installed|updates} [glob_exp1] […]
5、查找:
  yum search string1 [string2]
6、清除缓存:
  yum clean [packages|metadata|expire-cache|rpmdb|plugins|all]
7、构建缓存
  yum makecache
8、查看yum历史
  yum history
9、常用的命令行选项
  --nogpgcheck: 禁止进行gpg check
  -y: 自动回答为"yes"
  -q: 静默模式
  --disablerepo=repoidglob: 临时启用
  --noplugins: 禁用所有的插件
10、包组管理相关命令
  安装:yum groupinstall group1
  更新:yum groupupdate group1
  列表:yum grouplist groupwildcard
  删除:yum groupremove group1
  查看:yum groupinfo group1

示例:
1、安装

[root@linux4 ~]# yum install -y zsh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-34.el7_8.2 will be installed
--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================================================================Package                              Arch                                    Version                                              Repository                               Size
=================================================================================================================================================================================
Installing:zsh                                  x86_64                                  5.0.2-34.el7_8.2                                     server                                  2.4 MTransaction Summary
=================================================================================================================================================================================
Install  1 PackageTotal download size: 2.4 M
Installed size: 5.6 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.Installing : zsh-5.0.2-34.el7_8.2.x86_64                                                                                                                                   1/1 Verifying  : zsh-5.0.2-34.el7_8.2.x86_64                                                                                                                                   1/1 Installed:zsh.x86_64 0:5.0.2-34.el7_8.2                                                                                                                                                  Complete!

2、更新

[root@linux4 ~]# yum update zsh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No packages marked for update

3、卸载

[root@linux4 ~]# yum remove zsh
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-34.el7_8.2 will be erased
--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================================================================Package                              Arch                                    Version                                             Repository                                Size
=================================================================================================================================================================================
Removing:zsh                                  x86_64                                  5.0.2-34.el7_8.2                                    @server                                  5.6 MTransaction Summary
=================================================================================================================================================================================
Remove  1 PackageInstalled size: 5.6 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionErasing    : zsh-5.0.2-34.el7_8.2.x86_64                                                                                                                                   1/1 Verifying  : zsh-5.0.2-34.el7_8.2.x86_64                                                                                                                                   1/1 Removed:zsh.x86_64 0:5.0.2-34.el7_8.2                                                                                                                                                  Complete!
[root@linux4 ~]#

4、查看

[root@linux4 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                                  repo name                                                status
server                                                   server                                                   10,072
repolist: 10,072
[root@linux4 ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                              repo name                                           status
server                                               server                                              enabled: 10,072
repolist: 10,072
[root@linux4 ~]# yum repolist enabled
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                                  repo name                                                status
server                                                   server                                                   10,072
repolist: 10,072
[root@linux4 ~]# yum list installed
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
GConf2.x86_64                                                  3.2.6-8.el7                                     @server
NetworkManager.x86_64                                          1:1.18.8-1.el7                                  @anaconda
NetworkManager-libnm.x86_64                                    1:1.18.8-1.el7                                  @anaconda
NetworkManager-team.x86_64                                     1:1.18.8-1.el7                                  @anaconda
......

5、查找

[root@linux4 ~]# yum search mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
================================================== N/S matched: mysql ==================================================
MySQL-python.x86_64 : An interface to MySQL
akonadi-mysql.x86_64 : Akonadi MySQL backend support
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
dovecot-mysql.x86_64 : MySQL back end for dovecot
freeradius-mysql.x86_64 : MySQL support for freeradius
libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi
mha4mysql-manager.noarch : Master High Availability Manager and Tools for MySQL, Manager Package
mha4mysql-node.noarch : Master High Availability Manager and Tools for MySQL, Node Package
mysql-connector-java.noarch : Official JDBC driver for MySQL
mysql-connector-odbc.x86_64 : ODBC driver for MySQL
pcp-pmda-mysql.x86_64 : Performance Co-Pilot (PCP) metrics for MySQL
perl-DBD-MySQL.x86_64 : A MySQL interface for Perl
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
qt-mysql.i686 : MySQL driver for Qt's SQL classes
qt-mysql.x86_64 : MySQL driver for Qt's SQL classes
qt3-MySQL.i686 : MySQL drivers for Qt 3's SQL classes
qt3-MySQL.x86_64 : MySQL drivers for Qt 3's SQL classes
qt5-qtbase-mysql.i686 : MySQL driver for Qt5's SQL classes
qt5-qtbase-mysql.x86_64 : MySQL driver for Qt5's SQL classes
redland-mysql.x86_64 : MySQL storage support for Redland
rsyslog-mysql.x86_64 : MySQL support for rsyslog
mariadb.x86_64 : A community developed branch of MySQL
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clientsName and summary matches only, use "search all" for everything.
[root@linux4 ~]#

6、清除缓存

[root@linux4 ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: server
Cleaning up list of fastest mirrors
[root@linux4 ~]#

7、构建缓存

[root@linux4 ~]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
server                                                                                           | 3.6 kB  00:00:00
(1/4): server/group_gz                                                                           | 153 kB  00:00:00
(2/4): server/filelists_db                                                                       | 7.2 MB  00:00:00
(3/4): server/other_db                                                                           | 2.6 MB  00:00:00
(4/4): server/primary_db                                                                         | 6.1 MB  00:00:00
Metadata Cache Created
[root@linux4 ~]#

8、yum历史

[root@linux4 ~]# yum history
Loaded plugins: fastestmirror
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------23 | remove zsh               | 2022-09-21 22:27 | Erase          |    1   22 | install -y zsh           | 2022-09-21 22:24 | Install        |    1  <21 | groupremove -y Security  | 2022-09-21 21:22 | Erase          |    1 > 20 | groupinstall Security To | 2022-09-21 21:21 | Install        |    3   19 | install createrepo       | 2022-09-20 15:44 | Install        |    3   18 | install -y zsh           | 2022-09-20 15:09 | Install        |    1   17 | erase zsh                | 2022-09-20 15:09 | Erase          |    1   16 | install -y zsh           | 2022-09-20 15:09 | Install        |    1   15 | remove zsh               | 2022-09-20 15:09 | Erase          |    1   14 | reinstall zsh*           | 2022-09-20 15:07 | Reinstall      |    1  <13 | install -y at*           | 2022-09-19 09:12 | Install        |  149 > 12 | install mail*            | 2022-09-18 22:37 | Install        |    5   11 | install -y bison flex re | 2022-09-07 11:00 | Install        |   17   10 | groupinstall -y Developm | 2022-09-07 10:59 | Install        |   56   9 | install -y tree          | 2022-07-29 11:03 | Install        |    1   8 | install java*            | 2022-07-27 09:08 | Install        |  212   7 | install -y keepalived*   | 2022-07-26 00:35 | Install        |    4   6 | install lrz*             | 2022-07-21 23:44 | Install        |    1   5 | install -y unzip         | 2022-07-21 21:54 | Install        |    1  <4 | install -y perl*         | 2022-07-20 18:20 | Install        |  337 >
history list
[root@linux4 ~]#

9、包组相关

################ yum grouplist #################
[root@linux4 ~]# yum grouplist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Environment Groups:Minimal InstallCompute NodeInfrastructure ServerFile and Print ServerBasic Web ServerVirtualization HostServer with GUIGNOME DesktopKDE Plasma WorkspacesDevelopment and Creative Workstation
Installed Groups:Development ToolsLegacy UNIX Compatibility
Available Groups:Compatibility LibrariesConsole Internet ToolsGraphical Administration ToolsScientific SupportSecurity ToolsSmart Card SupportSystem Administration ToolsSystem Management
Done################ yum groupinstall  #################
[root@linux4 ~]# yum groupinstall -y "Security Tools"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package scap-security-guide.noarch 0:0.1.49-13.el7.centos will be installed
--> Finished Dependency ResolutionDependencies Resolved========================================================================================================================Package                           Arch                 Version                              Repository            Size
========================================================================================================================
Installing for group install "Security Tools":scap-security-guide               noarch               0.1.49-13.el7.centos                 server               7.9 MTransaction Summary
========================================================================================================================
Install  1 PackageTotal download size: 7.9 M
Installed size: 217 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : scap-security-guide-0.1.49-13.el7.centos.noarch                                                      1/1 Verifying  : scap-security-guide-0.1.49-13.el7.centos.noarch                                                      1/1 Installed:scap-security-guide.noarch 0:0.1.49-13.el7.centos                                                                     Complete!
[root@linux4 ~]# ################ yum groupupdate  #################
[root@linux4 ~]# yum groupupdate -y "Security Tools"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update################ yum groupinfo  #################
[root@linux4 ~]# yum groupinfo "Security Tools"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfileGroup: Security ToolsGroup-Id: security-toolsDescription: Security tools for integrity and trust verification.Default Packages:=scap-security-guideOptional Packages:aidehmaccalcopenscapopenscap-utilsscap-security-guide-docscap-workbenchstrongimcvtncfhhtpm-quote-toolstpm-toolstpm2-toolstrousers
[root@linux4 ~]# ################ yum groupremove  #################
[root@linux4 ~]# yum groupremove -y "Security Tools"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No environment named Security Tools exists
Resolving Dependencies
--> Running transaction check
---> Package scap-security-guide.noarch 0:0.1.49-13.el7.centos will be erased
--> Finished Dependency ResolutionDependencies Resolved========================================================================================================================Package                           Arch                 Version                             Repository             Size
========================================================================================================================
Removing:scap-security-guide               noarch               0.1.49-13.el7.centos                @server               217 MTransaction Summary
========================================================================================================================
Remove  1 PackageInstalled size: 217 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionErasing    : scap-security-guide-0.1.49-13.el7.centos.noarch                                                      1/1 Verifying  : scap-security-guide-0.1.49-13.el7.centos.noarch                                                      1/1 Removed:scap-security-guide.noarch 0:0.1.49-13.el7.centos                                                                     Complete!
[root@linux4 ~]#

四、yum源配置
  yum配置文件:
    /etc/yum.conf 为所有仓库提供公共配置
    /etc/yum.repos.d/*.repo 为仓库的指向提供配置

  仓库定义
    [repositoryID] 仓库ID
    name=SOME name for this repository 仓库名
    baseurl=url://path/to/repository 路径,可以有多个,每个写一行
    enabled={1|0} 默认1
    gpgckeck={1|0} 是否校验完整性及来源合法性(可选)
    gpgkey=URL(可选)
    enablegroups={1|0}(可选)
    failovermethod={roundrobin|priority}(可选,url有多个时,指定选择顺序)
    cost= 开销,默认1000(可选)

  yum的repo配置文件中可用的变量
     $releasever: 当前OS的发行版的主版本号
     $arch: 平台
     $basearch: 基础平台
  

本地yum源配置样例

[root@linux4 ~]# cat /etc/yum.repos.d/CentOS-Base.repo
[server]
name=server
baseurl=file:///mnt
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

网络源配置,参考如下链接:
点击此处查看网络yum源配置
https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b1172sF6t

Linux软件包管理工具-yum相关推荐

  1. 【Linux基础】Linux软件包管理器yum的使用指南rzsz安装

    [Linux基础]Linux软件包管理器yum的使用指南|rzsz安装 前言 主页: 潮.eth的博客_CSDN博客-C学习,C++学习,数据结构and算法领域博主 Linux基础专栏: Linux基 ...

  2. linux软件包管理工具,Linux 软件包管理器-----yum配置详解一

    一.yum简介 Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器.基于RPM包管理,能够从指定 ...

  3. Linux系统编程3:基础篇之详解Linux软件包管理器yum

    文章目录 (1)什么是软件包 A:软件包 B:注意事项 C:yum基本使用 (2)安装rzsz (1)什么是软件包 A:软件包 区别Windows,在Linux下安装软件,第一种方法是下载程序源代码, ...

  4. 有关Linux 软件包管理器 yum的命令打字练习

    工欲善其事,必先利其器--首先我们需要有打字练习的工具 ,这里我推荐的是 金山打字通,下载链接为

  5. 【Linux】软件包管理器yum和编辑器vim(部分动图演示)

    工具的本质也是指令 文章目录 一.Linux 软件包管理器 yum 1.什么是软件包 2.第一个软件rzsz 3.yum的扩展 二.Linux编辑器-vim使用 1.vim的基本概念 2.vim的基本 ...

  6. 07 Linux软件包管理

    Linux软件包管理 rpm软件包管理 Yum软件包管理 Dnf软件包管理 源码编译安装 准备工作 挂载iso镜像 将光驱挂载到系统中 [root@myserver dev]# mount /dev/ ...

  7. 【Linux扩展】五、软件包管理 ——RPM(RedHat Package Manager,RedHat软件包管理工具)查询与卸载、YUM仓库配置

    软件包管理 5.1 RPM 5.1.1 RPM 概述 5.1.2 RPM 查询命令(rpm -qa) 5.1.3 RPM 卸载命令(rpm -e) 5.2 YUM 仓库配置 5.2.1 YUM 概述 ...

  8. 【Linux系统】开发工具(上) {软件包管理器yum,更新yum源,文本编辑器vim,vim的四种基本模式,vim指令集,代码编译器gcc/g++}

    一.软件包管理器:yum 1.1 yum是什么? Linux下软件的安装方法: 源码安装:下载源码,在本地自行编译,然后才能安装. rpm安装:红帽软件包管理工具,属于安装包安装. yum安装:本身会 ...

  9. linux软件包管理之rpm 、yum基本使用

    linux软件包管理之rpm .yum基本使用 一.RPM RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是 ...

  10. Linux_09 Linux软件包管理 rpm与yum

    Linux软件包管理 rpm与yum 文件的压缩与打包 rpm安装软件 yum安装删除软件 yum进阶 一. 文件的打包 与压缩 压缩:指通过某些算法,将文件尺寸进行相应的缩小,同时不损失文件的内容. ...

最新文章

  1. 2021年大数据Spark(二十六):SparkSQL数据处理分析
  2. 清空list_3. Python3轻食丨一个故事看懂List所有用法:1年级1班的班级生活
  3. php7 出现Class 'DOMDocument' not found的解决方法
  4. 无法设置共享文件夹的解决方法收集
  5. 洛谷 P1983 车站分级
  6. leetcode 221. Maximal Square | 221. 最大正方形(优化的暴力解法+动态规划解法)
  7. [开源] .Net ORM FreeSql 1.10.0 稳步向前
  8. 3位高二女生用大数据成功预测地铁出站人数 | 00后正在抛弃你
  9. xampp启动Apache报错 1、Error: Apache shutdown unexpectedly. 2、Unclean shutdown of previous Apache run?
  10. 把数字随机分成 php,php随机数 微信随机生成红包金额算法php版
  11. vue 匹配键盘输入_vue如何监听键盘事件中的按键?
  12. indesign教程,如何创建和编辑图层?
  13. php创建游戏房间思路,php设计模式之建造器模式分析【星际争霸游戏案例】
  14. 如何验证 nginx.conf 是否配置正确
  15. 泛微oa系统什么框架_泛微OA办公系统是什么,怎么使用_使用方法_使用平台_企业服务汇...
  16. 程序人生 - 农夫山泉、恒大冰泉、怡宝等矿泉水品牌的产品有哪些区别?
  17. Struts2进阶版
  18. 计算机图形与OpenGL学习五(二维几何变换1.平移、旋转、缩放)
  19. 生成组合仿射变换矩阵,裁剪+缩放+平移+斜切+旋转
  20. 卸载3dMax2012流程

热门文章

  1. Tent-Logistic-Cosine混沌映射(提供参考文献及Matlab代码)
  2. mysql崩 数据同步_MySQL5.7 大大降低了半同步复制-数据丢失的风险
  3. 【论文阅读笔记】用于真实图像超分辨率的一种局部判别学习方法(LDL)
  4. 哈夫曼树的构造与哈夫曼编码
  5. html修改网站图标,分享内容,分享图标等
  6. MaixII-Dock(v831)学习笔记——PWM
  7. i9级E52450处理器_2019年度十款热门处理器横评 一场没有硝烟的PK
  8. Python学习week4
  9. 福利,架构师之路定制T恤
  10. Microsoft Visual Studio 2010升级Service Pack1问题