zoukankan      html  css  js  c++  java
  • Linux_yum工具的使用

    yum工具的使用

    1. rpm的弊端


    当用rpm安装软件时,若遇到有依赖关系的软件,必须先安装依赖的软件才能继续安装我们要安装的软件,当依赖关系很复杂的情况下,这种安装方式就很让人头疼

    2. yum的优劣势


    • yum最大的优势就是能够解决rpm的依赖问题,yum能够自动解决软件安装时的依赖关系
    • yum的缺陷就是如果在未完成安装的情况下强行中止安装过程,下次再安装时将无法解决依赖关系

    dnf是redhat7上用来代替yum的一个工具,其存在的意义就是处理yum的缺陷,但其用法与yum是完全一样的,甚至连选项都是一样的,你可以理解为dnf就是yum。

    3. 什么是yum及其作用


    • yum 是“yellow dogUpdate Modifiled ”的简称
    • 它能够实现rpm管理的所有操作,并能够自动解决各rpm包之间的依赖关系。yum是rpm的前端工具,是基于rpm来实现软件的管理的一个工具。

    4. 挂载光盘


    • 在虚拟机中连接镜像
    • 执行挂载命令

    演示如下:

    [root@localhost ~]# mount /dev/cdrom /mnt  //用mount挂载到mnt中
    mount: /mnt: WARNING: device write-protected, mounted read-only.  //显示只读
    [root@localhost ~]# ls /mnt/  //查看mnt下的文件
    AppStream  EULA              images      RPM-GPG-KEY-redhat-beta
    BaseOS     extra_files.json  isolinux    RPM-GPG-KEY-redhat-release
    EFI        GPL               media.repo  TRANS.TBL
    [root@localhost ~]#
    

    5. yum的工作原理


    yum的工作是由两个部分来合作:

    • 第一个部分是yum服务器
    • 第二个部分就是client的yum工具

    软件仓库是用来放软件包的
    提供别人下载的方式有三种:

    • http 通过网页
    • ftp 通过分享
    • file 通过本地

    查看内核的版本号 // 这里用的是RedHat8.2

    [root@localhost ~]# uname -r
    4.18.0-193.el8.x86_64
    [root@localhost ~]# 
    

    6. yum的配置文件


    • 配置文件有哪些:
      • /etc/yum.conf 作用:为所有仓库提供公共配置
        注意:一般情况不要修改这个文件
      • /etc/yum.repo.d/abc.repo 作用:为仓库的指向提供配置
        注意:这里abc.repo只是举例,文件名可以任意修改但是后面要跟上 .repo后缀
    • yum的repo配置文件中可用的变量:
      • $releaseversion:当前OS的发行版的主版本号
      • $arch:平台类型
      • $basearch:基础平台

    为yum定义repo文件

    [Repo_Name]:仓库名称
    name:描述信息  //如果有2个仓库写的东西不能一样
    baseurl:仓库的具体路径,接受一下三种类型
        ftp://
        http://
        file:///     //前面两个左斜杠表示协议,本地的意思;后面的一个左斜杠表示系统根目录
    enable:可选值{1|0},1为启用此仓库,0为禁止此仓库
    gpgcheck:可选值{1|0},1为检查软件包来源合法性,o为不检查来源
        如果gpgcheck设为1,则必须用gpgcheck定义密钥文件的具体路径
        gpgkey=/PATH/TO/KEY   //gpgkey=key的位置
    

    查看一下yum.conf配置文件 // 这里是RedHat8.2

    • 注意:一般来说不修改下面的配置文件
    [root@localhost ~]# vi /etc/yum.conf 
    [main]
    gpgcheck=1   //默认检查软件包合法来源
    installonly_limit=3   //同时只能装三个
    clean_requirements_on_remove=True   //删除的时候清理它需要的包
    best=True   
    skip_if_unavailable=False //如果不可用就报错
    ~                                                                      
    

    7. yum仓库管理

    本地仓库和网路仓库是不能共存的,本地仓库的软件是固定的,网络仓库的软件是实时更新的,否则会有冲突


    7.1 yum本地仓库

    • 挂载光盘
    • 复制光盘内容到yum服务器
    1. 挂载光盘
    [root@localhost ~]# mount /dev/cdrom /mnt  
    mount: /mnt: WARNING: device write-protected, mounted read-only.  
    [root@localhost ~]#
    
    1. 在根目录下创建yum_local的目录,把mnt下的文件拷贝到yum_local里
    [root@localhost ~]# mkdir /yum_local
    [root@localhost ~]# cp -r /mnt/* /yum_local/
    [root@localhost ~]# 
    
    1. 配置repo文件
    [root@localhost ~]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# ls
    redhat.repo
    [root@localhost yum.repos.d]# vi redhat.repo 
    [BaseOS]  //第一个
    name=BaseOS //描述,区分大小写
    baseurl=file:///yum_local/BaseOS //地址
    gpgcheck=0 //光盘只读所以不用检查软件包来源
    enabled=1  //开机自启
    [AppStream]  //第二个
    name=AppStream
    baseurl=file:///yum_local/AppStream
    gpgcheck=0
    enabled=1
    
    1. 清空yum本地缓存
    [root@localhost yum.repos.d]# yum clean all
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    12 files removed
    [root@localhost yum.repos.d]# 
    
    1. 检查yum本地仓库
    [root@localhost yum.repos.d]# yum list all
    redland.i686                             1.0.17-14.el8                            AppStream
    redland.x86_64                           1.0.17-14.el8                            AppStream
    rest.i686                                0.8.1-2.el8                              AppStream
    rest.x86_64                              0.8.1-2.el8                              AppStream
    rhel-system-roles.noarch                 1.0-10.el8_1                             AppStream
    rhn-custom-info.noarch                   5.4.42-4.module+el8.1.0+3115+d1f204ad    AppStream
    rhn-setup-gnome.x86_64                   2.8.16-13.module+el8.1.0+3455+3ddf2832   AppStream
    

    7.2 yum网络仓库

    • 官方yum仓库(国外)
    • 阿里云yum仓库
    • 163yum仓库
    • xx大学yum仓库 //清华yum源 中科大yun源
    • epel源
    1. 从上面推荐的网站上搜索你想要的镜像 //这里用的是阿里云中镜像的下载地址
    [root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.os-8.repo       //复制的镜像下载地址用curl命令下载到本地
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2595  100  2595    0     0   4796      0 --:--:-- --:--:-- --:--:--  4787
    [root@localhost ~]# cd /etc/yum.repos.d/     
    [root@localhost yum.repos.d]# ls    //查看,镜像已经下载到本地
    CentOS-Base.repo
    [root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncsd' /etc/yum.repos.d/CentOS-Base.repo
    
    1. 编辑下载到本地的CentOS-Base.repo文件 //使用vim命令(%s/$releasever/8/g) 把这个配置文件里 $releasever替换成8
    [root@localhost yum.repos.d]# ls
    CentOS-Base.repo
    [root@localhost yum.repos.d]# vi CentOS-Base.repo 
    # CentOS-Base.repo
    #
    # The mirror system uses the connecting IP address of the client
    # update status of each mirror to pick mirrors that are updated 
    # geographically close to the client.  You should use this for C
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you c
    # remarked out baseurl= line instead.
    #
    #
    [base]
    name=CentOS-8 - Base - mirrors.aliyun.com
    failovermethod=priority
    baseurl=https://mirrors.aliyun.com/centos/8/BaseOS/$basearch/os/
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Offi
     
    #additional packages that may be useful
    [extras]
    name=CentOS-8 - Extras - mirrors.aliyun.com
    failovermethod=priority
    baseurl=https://mirrors.aliyun.com/centos/8/extras/$basearch/os/
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Offi
     
    #additional packages that extend functionality of existing packa
    [centosplus]
    name=CentOS-8 - Plus - mirrors.aliyun.com
    failovermethod=priority
    baseurl=https://mirrors.aliyun.com/centos/8/centosplus/$basearch
    gpgcheck=1
    enabled=0
    gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Offi
     
    [PowerTools]
    name=CentOS-8 - PowerTools - mirrors.aliyun.com
    failovermethod=priority
    baseurl=https://mirrors.aliyun.com/centos/8/PowerTools/$basearch
    gpgcheck=1
    enabled=0
    gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Offi
    
    
    [AppStream]
    name=CentOS-8 - AppStream - mirrors.aliyun.com
    failovermethod=priority
    baseurl=https://mirrors.aliyun.com/centos/8/AppStream/$basearch/
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Off
    
    1. 用dnf清空yum本地缓存
     [root@localhost ~]# dnf clean all
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management to register.
    12 files removed
    
    1. 检查yum本地仓库
    [root@localhost ~]# dnf list all
    rsyslog-gssapi.x86_64                8.1911.0-3.el8                        AppStream
    rsyslog-kafka.x86_64                 8.1911.0-3.el8                        AppStream
    rsyslog-mmaudit.x86_64               8.1911.0-3.el8                        AppStream
    rsyslog-mmjsonparse.x86_64           8.1911.0-3.el8                        AppStream
    rsyslog-mmkubernetes.x86_64          8.1911.0-3.el8                        AppStream
    rsyslog-mmnormalize.x86_64           8.1911.0-3.el8                        AppStream
    rsyslog-mmsnmptrapd.x86_64           8.1911.0-3.el8                        AppStream
    rsyslog-mysql.x86_64                 8.1911.0-3.el8                        AppStream
    rsyslog-pgsql.x86_64                 8.1911.0-3.el8                        AppStream
    rsyslog-relp.x86_64                  8.1911.0-3.el8                        AppStream
    rsyslog-snmp.x86_64                  8.1911.0-3.el8                        AppStream
    rtkit.x86_64                         0.11-19.el8                           AppStream
    

    8. yum管理软件


    8.1 yum命令用法

    yum [options] [command] [package...]    //yum跟上选项和子命令加包的名字
    

    8.2 常用的options:

    --nogpgcheck                //如果从网上下载包有时会检查gpgkey,此时可以使用此命令跳过gpgkey的检查
    -y                          //自动回答为"yes"
    -q                          //静默模式,安装时不输出信息至标准输出
    --disablerepo=repoidglob    //临时禁用此处指定的repo
    --enablerepo=repoidglob     //临时启用此处指定的repo
    --noplugins                 //禁用所有插件
    

    以下都用dnf命令做演示

    1. 自动回答“yes”进行安装
    [root@localhost ~]# dnf -y install zsh
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:02:25 ago on Tue 01 Dec 2020 12:22:05 AM CST.
    Dependencies resolved.
    =============================================================================================
     Package          Architecture        Version                      Repository           Size
    =============================================================================================
    Installing:
     zsh              x86_64              5.5.1-6.el8_1.2              BaseOS              2.9 M
    
    Transaction Summary
    =============================================================================================
    Install  1 Package
    
    Total size: 2.9 M
    Installed size: 7.2 M
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                     1/1 
      Installing       : zsh-5.5.1-6.el8_1.2.x86_64                                          1/1 
      Running scriptlet: zsh-5.5.1-6.el8_1.2.x86_64                                          1/1 
      Verifying        : zsh-5.5.1-6.el8_1.2.x86_64                                          1/1 
    Installed products updated.
    
    Installed:
      zsh-5.5.1-6.el8_1.2.x86_64                                                                 
    
    Complete!
    [root@localhost ~]# 
    
    1. 静默模式,不显示任何安装信息
    [root@localhost ~]# rpm -e zsh   //先卸载zsh
    [root@localhost ~]# dnf -y -q install zsh   //静默安装
    [root@localhost ~]# echo $?   //查看是否安装成功
    0                            //显示0代表成功,其他则失败;成功的路只有一条,失败的路千万条
    [root@localhost ~]# rpm -qa|grep zsh
    zsh-5.5.1-6.el8_1.2.x86_64       //安装成功
    [root@localhost ~]# 
    

    8.3 常用的command

    list            //列表
        all         //默认项
        available   //列出仓库中有的,但尚未安装的所有可用的包
        installed   //列出已经安装的包
        updates     //可用的升级
    
    clean           //清理缓存
        packages
        headers
        metadata
        dbcache
        all
    
    repolist        //显示repo列表及其简要信息
        all
        enabled     //默认项
        disabled
    
    install         //安装
        yum install packages [...]
    
    update          //升级
        yum update packages [...]
    update_to       //升级为指定版本
    
    downgrade package1 [package2 ...]   //降级
    
    remove|erase    //卸载
    
    info    //显示rpm -qi package的结果
        yum info packages
    
    provides|whatprovides   //查看指定的文件或特性是由哪个包安装生成的
    
    search string1 [string2 ...]    //以指定的关键字搜索程序包名及summary信息
    
    deplist package [package2 ...]  //显示指定包的依赖关系
    
    history     //查看yum的历史事务信息
    
    localinstall    //安装本地rpm包,自动解决依赖关系
    
    grouplist       //列出可用的组
    
    groupinstall "group name"   //安装一组软件
    
    createrepo命令    //创建yum仓库的元数据信息
    

    演示如下:
    list命令

    1. installed //列出已安装的包
    [root@localhost ~]# rpm -qa|grep zsh
    zsh-5.5.1-6.el8_1.2.x86_64
    [root@localhost ~]# dnf list installed|grep zsh //
    zsh.x86_64                                    5.5.1-6.el8_1.2                        @BaseOS   
    [root@localhost ~]# 
    
    
    1. available //列出未安装的包
    [root@localhost ~]# rpm -qa|grep zsh
    zsh-5.5.1-6.el8_1.2.x86_64 
    [root@localhost ~]# dnf list available|grep zsh
    zsh-html.noarch                                      5.5.1-6.el8_1.2                                   AppStream
    [root@localhost ~]# 
    
    
    1. updates //升级
    [root@localhost ~]#  dnf list updates
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:36:36 ago on Tue 01 Dec 2020 12:22:05 AM CST.
    [root@localhost ~]# 
    

    clean命令

    all //清理全部

    [root@localhost ~]# dnf clean all
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    12 files removed
    [root@localhost ~]# 
    

    repolist命令

    1. repolist //显示repo列表及其简要信息
    [root@localhost ~]# dnf repolist
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    repo id                                         repo name
    AppStream                                       AppStream
    BaseOS                                          BaseOS
    
    1. enabled | disabled//默认项
    [root@localhost ~]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# ls
    redhat.repo
    [root@localhost yum.repos.d]# vi redhat.repo  //修改一下BaseOS的enable方便演示下面命令
    [BaseOS]
    name=BaseOS
    baseurl=file:///yum_local/BaseOS
    gpgcheck=0
    enabled=0       //把enbaled设置为0
    [AppStream]
    name=AppStream
    baseurl=file:///yum_local/AppStream
    gpgcheck=0
    enabled=1
    [root@localhost yum.repos.d]# dnf repolist disabled  //查看不能用的仓库
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    repo id                                         repo name
    BaseOS                                          BaseOS
    [root@localhost yum.repos.d]# dnf repolist enabled  //查看可以用的仓库
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    repo id                                         repo name
    AppStream                                       AppStream
    [root@localhost yum.repos.d]# yum repolist all   //查看所有的
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    repo id                                    repo name                                   status
    AppStream                                  AppStream                                   enabled
    BaseOS                                     BaseOS                                      disabled
    [root@localhost yum.repos.d]# 
    

    install命令

    dnf -y install //安装时自动回答yes

    [root@localhost ~]# dnf -y install zsh wget vim
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    BaseOS                                                          90 MB/s | 2.3 MB     00:00    
    AppStream                                                      105 MB/s | 5.8 MB     00:00    
    Dependencies resolved.
    ===============================================================================================
     Package                 Architecture    Version                      Repository          Size
    ===============================================================================================
    Installing:
     vim-enhanced            x86_64          2:8.0.1763-13.el8            AppStream          1.4 M
     wget                    x86_64          1.19.5-8.el8_1.1             AppStream          735 k
     zsh                     x86_64          5.5.1-6.el8_1.2              BaseOS             2.9 M
    Installing dependencies:
     gpm-libs                x86_64          1.20.7-15.el8                AppStream           39 k
     vim-common              x86_64          2:8.0.1763-13.el8            AppStream          6.3 M
     vim-filesystem          noarch          2:8.0.1763-13.el8            AppStream           48 k
    
    Transaction Summary
    ===============================================================================================
    Install  6 Packages
    
    Total size: 11 M
    Installed size: 41 M
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                       1/1 
      Installing       : vim-filesystem-2:8.0.1763-13.el8.noarch                               1/6 
      Installing       : vim-common-2:8.0.1763-13.el8.x86_64                                   2/6 
      Installing       : gpm-libs-1.20.7-15.el8.x86_64                                         3/6 
      Running scriptlet: gpm-libs-1.20.7-15.el8.x86_64                                         3/6 
      Installing       : vim-enhanced-2:8.0.1763-13.el8.x86_64                                 4/6 
      Installing       : wget-1.19.5-8.el8_1.1.x86_64                                          5/6 
      Running scriptlet: wget-1.19.5-8.el8_1.1.x86_64                                          5/6 
      Installing       : zsh-5.5.1-6.el8_1.2.x86_64                                            6/6 
      Running scriptlet: zsh-5.5.1-6.el8_1.2.x86_64                                            6/6 
      Running scriptlet: vim-common-2:8.0.1763-13.el8.x86_64                                   6/6 
      Verifying        : zsh-5.5.1-6.el8_1.2.x86_64                                            1/6 
      Verifying        : gpm-libs-1.20.7-15.el8.x86_64                                         2/6 
      Verifying        : vim-common-2:8.0.1763-13.el8.x86_64                                   3/6 
      Verifying        : vim-enhanced-2:8.0.1763-13.el8.x86_64                                 4/6 
      Verifying        : vim-filesystem-2:8.0.1763-13.el8.noarch                               5/6 
      Verifying        : wget-1.19.5-8.el8_1.1.x86_64                                          6/6 
    Installed products updated.
    
    Installed:
      gpm-libs-1.20.7-15.el8.x86_64                 vim-common-2:8.0.1763-13.el8.x86_64            
      vim-enhanced-2:8.0.1763-13.el8.x86_64         vim-filesystem-2:8.0.1763-13.el8.noarch        
      wget-1.19.5-8.el8_1.1.x86_64                  zsh-5.5.1-6.el8_1.2.x86_64                     
    
    Complete!
    [root@localhost ~]# 
    

    remove|erase //卸载

    [root@localhost ~]# dnf -y remove zsh
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Dependencies resolved.
    ===============================================================================================
     Package          Architecture        Version                       Repository            Size
    ===============================================================================================
    Removing:
     zsh              x86_64              5.5.1-6.el8_1.2               @BaseOS              7.2 M
    
    Transaction Summary
    ===============================================================================================
    Remove  1 Package
    
    Freed space: 7.2 M
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                       1/1 
      Running scriptlet: zsh-5.5.1-6.el8_1.2.x86_64                                            1/1 
      Erasing          : zsh-5.5.1-6.el8_1.2.x86_64                                            1/1 
      Running scriptlet: zsh-5.5.1-6.el8_1.2.x86_64                                            1/1 
      Verifying        : zsh-5.5.1-6.el8_1.2.x86_64                                            1/1 
    Installed products updated.
    
    Removed:
      zsh-5.5.1-6.el8_1.2.x86_64                                                                   
    
    Complete!
    [root@localhost ~]# 
    
    

    info /显示rpm -qi packages的结果

    [root@localhost ~]# dnf info wget
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:07:25 ago on Tue 01 Dec 2020 12:53:04 PM CST.
    Installed Packages
    Name         : wget
    Version      : 1.19.5
    Release      : 8.el8_1.1
    Architecture : x86_64
    Size         : 2.9 M
    Source       : wget-1.19.5-8.el8_1.1.src.rpm
    Repository   : @System
    From repo    : AppStream
    Summary      : A utility for retrieving files using the HTTP or FTP protocols
    URL          : http://www.gnu.org/software/wget/
    License      : GPLv3+
    Description  : GNU Wget is a file retrieval utility which can use either the HTTP or
                 : FTP protocols. Wget features include the ability to work in the
                 : background while you are logged out, recursive retrieval of
                 : directories, file name wildcard matching, remote file timestamp
                 : storage and comparison, use of Rest with FTP servers and Range with
                 : HTTP servers to retrieve files over slow or unstable connections,
                 : support for Proxy servers, and configurability.
    
    [root@localhost ~]# 
    
    

    provides|whatprovides //查看指定的文件或特性是由哪个包安装生成

    [root@localhost ~]# dnf provides *bin/ls    //不确定ls在什么位置所以加*号
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:22:52 ago on Tue 01 Dec 2020 12:53:04 PM CST.
    coreutils-8.30-6.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
    Repo        : @System
    Matched from:
    Provide    : /bin/ls
    
    coreutils-8.30-6.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
    Repo        : BaseOS
    Matched from:
    Provide    : /bin/ls
    
    coreutils-single-8.30-6.el8.x86_64 : coreutils multicall binary
    Repo        : BaseOS
    Matched from:
    Provide    : /bin/ls
    [root@localhost ~]# dnf whatprovides *bin/ls
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:26:23 ago on Tue 01 Dec 2020 12:53:04 PM CST.
    coreutils-8.30-6.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
    Repo        : @System
    Matched from:
    Provide    : /bin/ls
    
    coreutils-8.30-6.el8.x86_64 : A set of basic GNU tools commonly used in shell scripts
    Repo        : BaseOS
    Matched from:
    Provide    : /bin/ls
    
    coreutils-single-8.30-6.el8.x86_64 : coreutils multicall binary
    Repo        : BaseOS
    Matched from:
    Provide    : /bin/ls
    [root@localhost ~]# 
    

    search string1 [string2 ...] //以指定的关键字搜索程序及summary信息

    [root@localhost ~]# dnf search wget
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:28:08 ago on Tue 01 Dec 2020 12:53:04 PM CST.
    ================================= Name Exactly Matched: wget ==================================
    wget.x86_64 : A utility for retrieving files using the HTTP or FTP protocols
    [root@localhost ~]# dnf search zsh
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:28:19 ago on Tue 01 Dec 2020 12:53:04 PM CST.
    ================================== Name Exactly Matched: zsh ==================================
    zsh.x86_64 : Powerful interactive shell   //第一个包
    ================================= Name & Summary Matched: zsh =================================
    zsh-html.noarch : Zsh shell manual in html format //第二个包
    [root@localhost ~]# 
    

    deplist package [package2 ...] //显示指定包的依赖关系

    [root@localhost ~]# dnf deplist wget
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:02:12 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    package: wget-1.19.5-8.el8_1.1.x86_64
      dependency: /bin/sh
       provider: bash-4.4.19-10.el8.x86_64
      dependency: /sbin/install-info
       provider: info-6.5-6.el8.x86_64
      dependency: libc.so.6(GLIBC_2.17)(64bit)
       provider: glibc-2.28-101.el8.x86_64
      dependency: libgnutls.so.30()(64bit)
       provider: gnutls-3.6.8-9.el8.x86_64
      dependency: libgnutls.so.30(GNUTLS_3_4)(64bit)
       provider: gnutls-3.6.8-9.el8.x86_64
      dependency: libgnutls.so.30(GNUTLS_3_6_3)(64bit)
       provider: gnutls-3.6.8-9.el8.x86_64
      dependency: libgpgme.so.11()(64bit)
       provider: gpgme-1.10.0-6.el8.x86_64
      dependency: libgpgme.so.11(GPGME_1.0)(64bit)
       provider: gpgme-1.10.0-6.el8.x86_64
      dependency: libgpgme.so.11(GPGME_1.1)(64bit)
       provider: gpgme-1.10.0-6.el8.x86_64
      dependency: libidn2.so.0()(64bit)
       provider: libidn2-2.2.0-1.el8.x86_64
      dependency: libidn2.so.0(IDN2_0.0.0)(64bit)
       provider: libidn2-2.2.0-1.el8.x86_64
      dependency: libmetalink.so.3()(64bit)
       provider: libmetalink-0.1.3-7.el8.x86_64
      dependency: libnettle.so.6()(64bit)
       provider: nettle-3.4.1-1.el8.x86_64
      dependency: libnettle.so.6(NETTLE_6)(64bit)
       provider: nettle-3.4.1-1.el8.x86_64
      dependency: libpsl.so.5()(64bit)
       provider: libpsl-0.20.2-5.el8.x86_64
      dependency: libuuid.so.1()(64bit)
       provider: libuuid-2.32.1-22.el8.x86_64
      dependency: libuuid.so.1(UUID_1.0)(64bit)
       provider: libuuid-2.32.1-22.el8.x86_64
      dependency: libz.so.1()(64bit)
       provider: zlib-1.2.11-13.el8.x86_64
      dependency: rtld(GNU_HASH)
       provider: glibc-2.28-101.el8.i686
       provider: glibc-2.28-101.el8.x86_64
    [root@localhost ~]# 
    

    history //查看yum的历史事务信息

    [root@localhost ~]# dnf history
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    ID     | Command line             | Date and time    | Action(s)      | Altered
    -------------------------------------------------------------------------------
         5 | -y remove zsh            | 2020-12-01 12:56 | Removed        |    1   
         4 | -y install zsh wget vim  | 2020-12-01 12:53 | Install        |    6  <
         3 | -y -q install zsh        | 2020-12-01 00:35 | Install        |    1 ><
         2 | -y install zsh           | 2020-12-01 00:24 | Install        |    1 > 
         1 |                          | 2020-11-28 15:04 | Install        |  420 EE
    [root@localhost ~]# 
    

    history info //查看某一条的详细信息

    [root@localhost ~]# dnf history
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    ID     | Command line             | Date and time    | Action(s)      | Altered
    -------------------------------------------------------------------------------
         5 | -y remove zsh            | 2020-12-01 12:56 | Removed        |    1   
         4 | -y install zsh wget vim  | 2020-12-01 12:53 | Install        |    6  <
         3 | -y -q install zsh        | 2020-12-01 00:35 | Install        |    1 ><
         2 | -y install zsh           | 2020-12-01 00:24 | Install        |    1 > 
         1 |                          | 2020-11-28 15:04 | Install        |  420 EE
    [root@localhost ~]#  dnf history info 4   //后面加上info和你想看的第几条命令
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Transaction ID : 4
    Begin time     : Tue 01 Dec 2020 12:53:08 PM CST
    Begin rpmdb    : 417:3d3b11ecfb8c229d0915cef350b906880c4b8bbb
    End time       : Tue 01 Dec 2020 12:53:18 PM CST (10 seconds)
    End rpmdb      : 423:15f529b46ad1dc8cd0ed944f727c8a0e03f259ce
    User           : root <root>
    Return-Code    : Success
    Releasever     : 8
    Command Line   : -y install zsh wget vim
    Packages Altered:
        Install zsh-5.5.1-6.el8_1.2.x86_64              @BaseOS
        Install gpm-libs-1.20.7-15.el8.x86_64           @AppStream
        Install vim-common-2:8.0.1763-13.el8.x86_64     @AppStream
        Install vim-enhanced-2:8.0.1763-13.el8.x86_64   @AppStream
        Install vim-filesystem-2:8.0.1763-13.el8.noarch @AppStream
        Install wget-1.19.5-8.el8_1.1.x86_64            @AppStream
    [root@localhost ~]# 
    

    8.4 具体实例

    8.4.1 搜索软件包

    1. 列出软件仓库中可用的软件
    [root@localhost ~]# yum list all
    rpm-plugin-ima.x86_64               4.14.2-37.el8                          BaseOS   
    rpm-plugin-prioreset.x86_64         4.14.2-37.el8                          BaseOS   
    rpm-plugin-syslog.x86_64            4.14.2-37.el8                          BaseOS   
    rpm-sign.x86_64                     4.14.2-37.el8                          BaseOS   
    rpmdevtools.noarch                  8.10-7.el8                             AppStream
    rpmemd.x86_64                       1.6.1-1.el8                            AppStream
    rpmlint.noarch                      1.10-13.2.el8                          AppStream
    rrdtool.i686                        1.7.0-16.el8                           AppStream
    rrdtool.x86_64                      1.7.0-16.el8                           AppStream
    rrdtool-perl.x86_64                 1.7.0-16.el8                           AppStream
    rsync.x86_64                        3.1.3-7.el8                            BaseOS   
    rsync-daemon.noarch                 3.1.3-7.el8                            BaseOS   
    
    1. 进行模糊查找
    [root@localhost ~]# yum list|grep ftp   //过滤ftp
    ftp.x86_64                                           0.17-78.el8                                       AppStream 
    lftp.i686                                            4.8.4-1.el8                                       AppStream 
    lftp.x86_64                                          4.8.4-1.el8                                       AppStream 
    lftp-scripts.noarch                                  4.8.4-1.el8                                       AppStream 
    python3-requests-ftp.noarch                          0.3.1-11.el8                                      AppStream 
    syslinux-tftpboot.noarch                             6.04-4.el8                                        BaseOS    
    tftp.x86_64                                          5.2-24.el8                                        AppStream 
    tftp-server.x86_64                                   5.2-24.el8                                        AppStream 
    vsftpd.x86_64                                        3.0.3-31.el8                                      AppStream 
    
    
    1. 列出软件包详情
    [root@localhost ~]# yum info ftp
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:45:30 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Available Packages
    Name         : ftp
    Version      : 0.17
    Release      : 78.el8
    Architecture : x86_64
    Size         : 70 k
    Source       : ftp-0.17-78.el8.src.rpm
    Repository   : AppStream
    Summary      : The standard UNIX FTP (File Transfer Protocol) client
    URL          : ftp://ftp.linux.org.uk/pub/linux/Networking/netkit
    License      : BSD with advertising
    Description  : The ftp package provides the standard UNIX command-line FTP (File
                 : Transfer Protocol) client.  FTP is a widely used protocol for
                 : transferring files over the Internet and for archiving files.
                 : 
                 : If your system is on a network, you should install ftp in order to do
                 : file transfers.
    
    [root@localhost ~]# 
    
    

    8.4.2 安装软件包

    1. 安装软件只需要给出软件名称
    [root@localhost ~]# yum -y install tree
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:04:50 ago on Tue 01 Dec 2020 02:43:18 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package         Architecture      Version                    Repository       Size
    ====================================================================================
    Installing:
     tree            x86_64            1.7.0-15.el8               base             59 k
    
    Transaction Summary
    ====================================================================================
    Install  1 Package
    
    Total download size: 59 k
    Installed size: 109 k
    Downloading Packages:
    tree-1.7.0-15.el8.x86_64.rpm                        217 kB/s |  59 kB     00:00    
    ------------------------------------------------------------------------------------
    Total                                               215 kB/s |  59 kB     00:00     
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                            1/1 
      Installing       : tree-1.7.0-15.el8.x86_64                                   1/1 
      Running scriptlet: tree-1.7.0-15.el8.x86_64                                   1/1 
      Verifying        : tree-1.7.0-15.el8.x86_64                                   1/1 
    Installed products updated.
    
    Installed:
      tree-1.7.0-15.el8.x86_64                                                          
    
    Complete!
    [root@localhost ~]# 
    
    1. 安装网络上rpm包 //文件太大时不推荐,可能会中断。
    [root@localhost ~]# yum -y install http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:07:27 ago on Tue 01 Dec 2020 02:43:18 PM CST.
    wget-1.14-18.el7_6.1.x86_64.rpm                      24 kB/s | 547 kB     00:23    
    Dependencies resolved.
    ====================================================================================
     Package       Architecture    Version                  Repository             Size
    ====================================================================================
    Installing:
     wget          x86_64          1.14-18.el7_6.1          @commandline          547 k
    
    Transaction Summary
    ====================================================================================
    Install  1 Package
    
    Total size: 547 k
    Installed size: 2.0 M
    Downloading Packages:
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                            1/1 
      Installing       : wget-1.14-18.el7_6.1.x86_64                                1/1 
      Running scriptlet: wget-1.14-18.el7_6.1.x86_64                                1/1 
      Verifying        : wget-1.14-18.el7_6.1.x86_64                                1/1 
    Installed products updated.
    
    Installed:
      wget-1.14-18.el7_6.1.x86_64                                                       
    
    Complete!
    [root@localhost ~]# rpm -qa|grep wget //查询包
    wget-1.14-18.el7_6.1.x86_64
    [root@localhost ~]#
    

    8.4.3 更新软件包

    [root@localhost ~]# dnf update wget
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:09:20 ago on Tue 01 Dec 2020 02:43:18 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package       Architecture    Version                     Repository          Size
    ====================================================================================
    Upgrading:
     wget          x86_64          1.19.5-8.el8_1.1            AppStream          735 k
    
    Transaction Summary
    ====================================================================================
    Upgrade  1 Package
    
    Total download size: 735 k
    Is this ok [y/N]: y
    Downloading Packages:
    wget-1.19.5-8.el8_1.1.x86_64.rpm                    713 kB/s | 735 kB     00:01    
    ------------------------------------------------------------------------------------
    Total                                               710 kB/s | 735 kB     00:01     
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                            1/1 
      Upgrading        : wget-1.19.5-8.el8_1.1.x86_64                               1/2 
      Running scriptlet: wget-1.19.5-8.el8_1.1.x86_64                               1/2 
      Running scriptlet: wget-1.14-18.el7_6.1.x86_64                                2/2 
      Cleanup          : wget-1.14-18.el7_6.1.x86_64                                2/2 
      Running scriptlet: wget-1.14-18.el7_6.1.x86_64                                2/2 
      Verifying        : wget-1.19.5-8.el8_1.1.x86_64                               1/2 
      Verifying        : wget-1.14-18.el7_6.1.x86_64                                2/2 
    Installed products updated.
    
    Upgraded:
      wget-1.19.5-8.el8_1.1.x86_64                                                      
    
    Complete!
    [root@localhost ~]# rpm -qa|grep wget
    wget-1.19.5-8.el8_1.1.x86_64
    [root@localhost ~]# 
    

    8.4.4 重装软件包

    1. 检查软件是否存在
    [root@localhost ~]# rpm -q vsftpd
    vsftpd-3.0.3-31.el8.x86_64
    [root@localhost ~]# 
    
    1. 检查vsftpd软件配置文件
    [root@localhost ~]# rpm -qc vsftpd
    /etc/logrotate.d/vsftpd
    /etc/pam.d/vsftpd
    /etc/vsftpd/ftpusers
    /etc/vsftpd/user_list
    /etc/vsftpd/vsftpd.conf
    [root@localhost ~]# 
    
    1. 不小心删除了vsftpd配置文件
    [root@localhost ~]# rm -f /etc/vsftpd/vsftpd.conf
    [root@localhost ~]# 
    
    1. 重新安装软件
    [root@localhost ~]# yum reinstall vsftpd
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:18:36 ago on Tue 01 Dec 2020 02:43:18 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package          Architecture     Version                Repository           Size
    ====================================================================================
    Reinstalling:
     vsftpd           x86_64           3.0.3-31.el8           AppStream           180 k
    
    Transaction Summary
    ====================================================================================
    
    Total download size: 180 k
    Installed size: 343 k
    Is this ok [y/N]: t^Hy^H^Hy
    Is this ok [y/N]: y
    Downloading Packages:
    vsftpd-3.0.3-31.el8.x86_64.rpm                      787 kB/s | 180 kB     00:00    
    ------------------------------------------------------------------------------------
    Total                                               779 kB/s | 180 kB     00:00     
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                            1/1 
      Running scriptlet: vsftpd-3.0.3-31.el8.x86_64                                 1/1 
      Reinstalling     : vsftpd-3.0.3-31.el8.x86_64                                 1/2 
      Running scriptlet: vsftpd-3.0.3-31.el8.x86_64                                 1/2 
      Running scriptlet: vsftpd-3.0.3-31.el8.x86_64                                 2/2 
      Cleanup          : vsftpd-3.0.3-31.el8.x86_64                                 2/2 
      Running scriptlet: vsftpd-3.0.3-31.el8.x86_64                                 2/2 
      Verifying        : vsftpd-3.0.3-31.el8.x86_64                                 1/2 
      Verifying        : vsftpd-3.0.3-31.el8.x86_64                                 2/2 
    Installed products updated.
    
    Reinstalled:
      vsftpd-3.0.3-31.el8.x86_64                                                        
    
    Complete!
    [root@localhost ~]# 
    
    1. 检查
    [root@localhost ~]# rpm -qc vsftpd
    /etc/logrotate.d/vsftpd
    /etc/pam.d/vsftpd
    /etc/vsftpd/ftpusers
    /etc/vsftpd/user_list
    /etc/vsftpd/vsftpd.conf
    [root@localhost ~]# 
    

    8.4.5 删除安装包

    1. 安装一个samba软件
    [root@localhost ~]# yum -y install samba
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:23:14 ago on Tue 01 Dec 2020 02:43:18 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package                   Architecture  Version                  Repository   Size
    ====================================================================================
    Installing:
     samba                     x86_64        4.11.2-13.el8            base        766 k
    Installing dependencies:
     avahi-libs                x86_64        0.7-19.el8               base         62 k
     cups-libs                 x86_64        1:2.2.6-33.el8           base        432 k
     libwbclient               x86_64        4.11.2-13.el8            base        117 k
     samba-client-libs         x86_64        4.11.2-13.el8            base        5.1 M
     samba-common              noarch        4.11.2-13.el8            base        212 k
     samba-common-libs         x86_64        4.11.2-13.el8            base        173 k
     samba-common-tools        x86_64        4.11.2-13.el8            base        472 k
     samba-libs                x86_64        4.11.2-13.el8            base        170 k
    
    Transaction Summary
    ====================================================================================
    Install  9 Packages
    
    Total download size: 7.4 M
    Installed size: 25 M
    Downloading Packages:
    (1/9): avahi-libs-0.7-19.el8.x86_64.rpm             508 kB/s |  62 kB     00:00    
    (2/9): libwbclient-4.11.2-13.el8.x86_64.rpm         244 kB/s | 117 kB     00:00    
    (3/9): samba-4.11.2-13.el8.x86_64.rpm               1.2 MB/s | 766 kB     00:00    
    (4/9): cups-libs-2.2.6-33.el8.x86_64.rpm            558 kB/s | 432 kB     00:00    
    (5/9): samba-common-libs-4.11.2-13.el8.x86_64.rpm   535 kB/s | 173 kB     00:00    
    (6/9): samba-common-4.11.2-13.el8.noarch.rpm        378 kB/s | 212 kB     00:00    
    (7/9): samba-common-tools-4.11.2-13.el8.x86_64.rpm  918 kB/s | 472 kB     00:00    
    (8/9): samba-libs-4.11.2-13.el8.x86_64.rpm          232 kB/s | 170 kB     00:00    
    (9/9): samba-client-libs-4.11.2-13.el8.x86_64.rpm   1.8 MB/s | 5.1 MB     00:02    
    ------------------------------------------------------------------------------------
    Total                                               2.2 MB/s | 7.4 MB     00:03     
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                            1/1 
      Installing       : avahi-libs-0.7-19.el8.x86_64                               1/9 
      Installing       : cups-libs-1:2.2.6-33.el8.x86_64                            2/9 
      Running scriptlet: samba-common-4.11.2-13.el8.noarch                          3/9 
      Installing       : samba-common-4.11.2-13.el8.noarch                          3/9 
      Running scriptlet: samba-common-4.11.2-13.el8.noarch                          3/9 
      Installing       : libwbclient-4.11.2-13.el8.x86_64                           4/9 
      Installing       : samba-common-libs-4.11.2-13.el8.x86_64                     5/9 
      Installing       : samba-client-libs-4.11.2-13.el8.x86_64                     6/9 
      Installing       : samba-libs-4.11.2-13.el8.x86_64                            7/9 
      Installing       : samba-common-tools-4.11.2-13.el8.x86_64                    8/9 
      Installing       : samba-4.11.2-13.el8.x86_64                                 9/9 
      Running scriptlet: samba-4.11.2-13.el8.x86_64                                 9/9 
      Running scriptlet: libwbclient-4.11.2-13.el8.x86_64                           9/9 
      Running scriptlet: samba-4.11.2-13.el8.x86_64                                 9/9 
      Verifying        : avahi-libs-0.7-19.el8.x86_64                               1/9 
      Verifying        : cups-libs-1:2.2.6-33.el8.x86_64                            2/9 
      Verifying        : libwbclient-4.11.2-13.el8.x86_64                           3/9 
      Verifying        : samba-4.11.2-13.el8.x86_64                                 4/9 
      Verifying        : samba-client-libs-4.11.2-13.el8.x86_64                     5/9 
      Verifying        : samba-common-4.11.2-13.el8.noarch                          6/9 
      Verifying        : samba-common-libs-4.11.2-13.el8.x86_64                     7/9 
      Verifying        : samba-common-tools-4.11.2-13.el8.x86_64                    8/9 
      Verifying        : samba-libs-4.11.2-13.el8.x86_64                            9/9 
    Installed products updated.
    
    Installed:
      avahi-libs-0.7-19.el8.x86_64             cups-libs-1:2.2.6-33.el8.x86_64          
      libwbclient-4.11.2-13.el8.x86_64         samba-4.11.2-13.el8.x86_64               
      samba-client-libs-4.11.2-13.el8.x86_64   samba-common-4.11.2-13.el8.noarch        
      samba-common-libs-4.11.2-13.el8.x86_64   samba-common-tools-4.11.2-13.el8.x86_64  
      samba-libs-4.11.2-13.el8.x86_64         
    
    Complete!
    
    
    1. 删除该软件包,不会删除依赖,但是最好不要使用删除软件操作
    [root@localhost ~]# yum -y erase samba
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Dependencies resolved.
    ====================================================================================
     Package                   Architecture  Version                 Repository    Size
    ====================================================================================
    Removing:
     samba                     x86_64        4.11.2-13.el8           @base        2.3 M
    Removing unused dependencies:
     avahi-libs                x86_64        0.7-19.el8              @base        159 k
     cups-libs                 x86_64        1:2.2.6-33.el8          @base        925 k
     libwbclient               x86_64        4.11.2-13.el8           @base         78 k
     samba-client-libs         x86_64        4.11.2-13.el8           @base         20 M
     samba-common              noarch        4.11.2-13.el8           @base        131 k
     samba-common-libs         x86_64        4.11.2-13.el8           @base        270 k
     samba-common-tools        x86_64        4.11.2-13.el8           @base        1.1 M
     samba-libs                x86_64        4.11.2-13.el8           @base        316 k
    
    Transaction Summary
    ====================================================================================
    Remove  9 Packages
    
    Freed space: 25 M
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                            1/1 
      Running scriptlet: samba-4.11.2-13.el8.x86_64                                 1/1 
      Running scriptlet: samba-4.11.2-13.el8.x86_64                                 1/9 
      Erasing          : samba-4.11.2-13.el8.x86_64                                 1/9 
      Running scriptlet: samba-4.11.2-13.el8.x86_64                                 1/9 
      Erasing          : samba-common-tools-4.11.2-13.el8.x86_64                    2/9 
      Erasing          : samba-libs-4.11.2-13.el8.x86_64                            3/9 
      Erasing          : samba-common-libs-4.11.2-13.el8.x86_64                     4/9 
      Erasing          : samba-client-libs-4.11.2-13.el8.x86_64                     5/9 
      Running scriptlet: libwbclient-4.11.2-13.el8.x86_64                           6/9 
      Erasing          : libwbclient-4.11.2-13.el8.x86_64                           6/9 
      Erasing          : samba-common-4.11.2-13.el8.noarch                          7/9 
      Erasing          : cups-libs-1:2.2.6-33.el8.x86_64                            8/9 
      Erasing          : avahi-libs-0.7-19.el8.x86_64                               9/9 
      Running scriptlet: avahi-libs-0.7-19.el8.x86_64                               9/9 
      Verifying        : avahi-libs-0.7-19.el8.x86_64                               1/9 
      Verifying        : cups-libs-1:2.2.6-33.el8.x86_64                            2/9 
      Verifying        : libwbclient-4.11.2-13.el8.x86_64                           3/9 
      Verifying        : samba-4.11.2-13.el8.x86_64                                 4/9 
      Verifying        : samba-client-libs-4.11.2-13.el8.x86_64                     5/9 
      Verifying        : samba-common-4.11.2-13.el8.noarch                          6/9 
      Verifying        : samba-common-libs-4.11.2-13.el8.x86_64                     7/9 
      Verifying        : samba-common-tools-4.11.2-13.el8.x86_64                    8/9 
      Verifying        : samba-libs-4.11.2-13.el8.x86_64                            9/9 
    Installed products updated.
    
    Removed:
      avahi-libs-0.7-19.el8.x86_64             cups-libs-1:2.2.6-33.el8.x86_64          
      libwbclient-4.11.2-13.el8.x86_64         samba-4.11.2-13.el8.x86_64               
      samba-client-libs-4.11.2-13.el8.x86_64   samba-common-4.11.2-13.el8.noarch        
      samba-common-libs-4.11.2-13.el8.x86_64   samba-common-tools-4.11.2-13.el8.x86_64  
      samba-libs-4.11.2-13.el8.x86_64         
    
    Complete!
    [root@localhost ~]# yum -y remove samba  //因为上面已经指向了删除命令所有这里显示没有找到文件删除
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    No match for argument: samba
    No packages marked for removal.
    Dependencies resolved.
    Nothing to do.
    Complete!
    [root@localhost ~]# 
    

    8.4.6 与仓库有关的命令

    1. 列出yum源可用的软件仓库
    [root@localhost ~]# yum repolist
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    repo id                   repo name
    AppStream                 CentOS-8 - AppStream - mirrors.aliyun.com
    base                      CentOS-8 - Base - mirrors.aliyun.com
    extras                    CentOS-8 - Extras - mirrors.aliyun.com
    [root@localhost ~]# 
    
    
    1. 列出全部yum源可用和禁用的仓库
    [root@localhost ~]# yum repolist all
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    repo id               repo name                                             status
    AppStream             CentOS-8 - AppStream - mirrors.aliyun.com             enabled
    PowerTools            CentOS-8 - PowerTools - mirrors.aliyun.com            disabled
    base                  CentOS-8 - Base - mirrors.aliyun.com                  enabled
    centosplus            CentOS-8 - Plus - mirrors.aliyun.com                  disabled
    extras                CentOS-8 - Extras - mirrors.aliyun.com                enabled
    [root@localhost ~]# 
    

    8.4.7 与缓存有关的命令

    1. 缓存yum源软件仓库,xml元数据文件
    [root@localhost ~]# yum makecache
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    CentOS-8 - Base - mirrors.aliyun.com                 27 kB/s | 3.9 kB     00:00    
    CentOS-8 - Extras - mirrors.aliyun.com               11 kB/s | 1.5 kB     00:00    
    CentOS-8 - AppStream - mirrors.aliyun.com            38 kB/s | 4.3 kB     00:00    
    Metadata cache created.
    [root@localhost ~]# 
    
    1. 缓存软件包,修改yum全局变量配置文件 //一般不做修改
    [root@localhost ~]# vi /etc/yum.conf
    
    [main]
    gpgcheck=1
    installonly_limit=3
    clean_requirements_on_remove=True
    best=True
    skip_if_unavailable=False
    
    1. 将软件下载到指定目录
    [root@localhost ~]# dnf -y install --downloadonly --downloaddir=/tmp/ wget
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:05:49 ago on Tue 01 Dec 2020 03:19:05 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package       Architecture    Version                     Repository          Size
    ====================================================================================
    Installing:
     wget          x86_64          1.19.5-8.el8_1.1            AppStream          735 k
    
    Transaction Summary
    ====================================================================================
    Install  1 Package
    
    Total download size: 735 k
    Installed size: 2.9 M
    DNF will only download packages for the transaction.
    Downloading Packages:
    wget-1.19.5-8.el8_1.1.x86_64.rpm                    1.0 MB/s | 735 kB     00:00    
    ------------------------------------------------------------------------------------
    Total                                               1.0 MB/s | 735 kB     00:00     
    Complete!
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.
    [root@localhost ~]# 
    

    8.4.8 与包组相关的命令

    1. 列出可用的组
    [root@localhost ~]# dnf grouplist
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:17:09 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Available Environment Groups:
       Server with GUI
       Server
       Workstation
       Custom Operating System
       Virtualization Host
    Installed Environment Groups:
       Minimal Install
    Available Groups:
       Legacy UNIX Compatibility
       Container Management
       Development Tools
       .NET Core Development
       Graphical Administration Tools
       Headless Management
       Network Servers
       RPM Development Tools
       Scientific Support
       Security Tools
       Smart Card Support
       System Tools
    [root@localhost ~]# 
    
    1. 安装包组
    [root@localhost ~]# dnf grouplist  //查看可用的包组
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:17:09 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Available Environment Groups:
       Server with GUI
       Server
       Workstation
       Custom Operating System
       Virtualization Host
    Installed Environment Groups:
       Minimal Install
    Available Groups:
       Legacy UNIX Compatibility
       Container Management
       Development Tools
       .NET Core Development
       Graphical Administration Tools
       Headless Management
       Network Servers
       RPM Development Tools
       Scientific Support
       Security Tools
       Smart Card Support
       System Tools
    [root@localhost ~]# dnf -y groups mark install "Development Tools"  //自动回答yes的方式安装Development Tools包组
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:33:01 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package            Architecture      Version              Repository          Size
    ====================================================================================
    Installing Groups:
     Development Tools                                                                 
    
    Transaction Summary
    ====================================================================================
    
    Complete!
    [root@localhost ~]# dnf grouplist  //查看可用包组
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:33:20 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Available Environment Groups:
       Server with GUI
       Server
       Workstation
       Custom Operating System
       Virtualization Host
    Installed Environment Groups:
       Minimal Install
    Installed Groups:    ////显示已安装的包组
       Development Tools   
    Available Groups:
       Legacy UNIX Compatibility
       Container Management
       .NET Core Development
       Graphical Administration Tools
       Headless Management
       Network Servers
       RPM Development Tools
       Scientific Support
       Security Tools
       Smart Card Support
       System Tools
    
    1. 删除包组
    [root@localhost ~]# dnf -y groups mark remove "Development Tools" //用自动回答yes的方式删除Development Tools包组
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:34:25 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Dependencies resolved.
    ====================================================================================
     Package            Architecture      Version              Repository          Size
    ====================================================================================
    Removing Groups:
     Development Tools                                                                 
    
    Transaction Summary
    ====================================================================================
    
    Complete!
    [root@localhost ~]# dnf grouplist  //查看可用包组;发现已经删除了
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:34:33 ago on Tue 01 Dec 2020 01:33:40 PM CST.
    Available Environment Groups:
       Server with GUI
       Server
       Workstation
       Custom Operating System
       Virtualization Host
    Installed Environment Groups:
       Minimal Install
    Available Groups:
       Legacy UNIX Compatibility
       Container Management
       Development Tools
       .NET Core Development
       Graphical Administration Tools
       Headless Management
       Network Servers
       RPM Development Tools
       Scientific Support
       Security Tools
       Smart Card Support
       System Tools
    [root@localhost ~]# 
    

    8.4. YUM签名检查机制

    • rpm软件提供组织redhat在构建rpm包时, 使用其私钥private key对 rpm进行签名
    • 客户端在使用rpm为了验证其合法性, 可以使用redhat提供的公钥public key进行签名检查
    1. 方式1:指定公钥位置
    [root@localhost ~]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# vi CentOS-Base.repo 
    [base]
    name=CentOS-8 - Base - mirrors.aliyun.com
    failovermethod=priority
    baseurl=https://mirrors.aliyun.com/centos/8/BaseOS/$basearch/os/
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
    
    1. 方式2:
      提前导入公钥 //需要公钥,这里不做演示

    2. 方式3:不进行签名验证
      配置文件中gpgcheck=0即可

    [root@localhost ~]# yum install tree --nogpgcheck
    Updating Subscription Management repositories.
    Unable to read consumer identity
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Last metadata expiration check: 0:11:13 ago on Tue 01 Dec 2020 03:31:48 PM CST.
    Package tree-1.7.0-15.el8.x86_64 is already installed.
    Dependencies resolved.
    Nothing to do.
    Complete!
    [root@localhost ~]# 
    
    
  • 相关阅读:
    markdown图片设置
    编程变量名
    c++ 子类构造函数初始化及父类构造初始化
    idea中解决Git反复输入代码的问题
    idea中修改git提交代码的用户名
    网络相关
    idea Controller层编译Mapper层报错
    java7与java8的新特性
    修改列名以及其数据类型
    修改数据库表的某个字段默认值
  • 原文地址:https://www.cnblogs.com/leixixi/p/14073400.html
Copyright © 2011-2022 走看看