暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Linux:「DNF」包管理器

Nephilim 2024-08-29
151

Tips:一些记录,一些笔记



2024/08/28

THURSDAY

Labor is harmless and sorrow injury body.

劳动无害,忧愁伤身。




01

DNF(Dandified Yum


DNF原先是Fedora Linux中的一个包管理器,它是基于YUM开发的,其主要特点是:快速、可靠、易用,以及优秀的用户体验。


DNF提供了许多强大的功能和命令行工具:

安装和升级软件包dnf install dnf update
查询和列出软件包
dnf search dnf list
删除软件包
dnf remove
清理系统
dnf clean
版本历史
dnf history
软件包组管理
dnf group
存储库管理
dnf repolist dnf config


02

DNF的安装

查看软件仓库:

    [root@ansible ~]# cat etc/system-release
    CentOS Linux release 7.9.2009 (Core)
    [root@ansible ~]#
    [root@ansible ~]# yum list | grep epel-release
    epel-release.noarch 7-14 epel
    [root@ansible ~]#
    [root@ansible ~]# yum repolist
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * base: mirrors.aliyun.com
    * extras: mirrors.aliyun.com
    * updates: mirrors.aliyun.com
    repo id repo name status
    base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
    epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,791
    extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 526
    updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 6,173
    repolist: 30,562
    [root@ansible ~]#


    执行安装:

      [root@ansible ~]# yum list | grep "^dnf"
      dnf.noarch 4.0.9.2-2.el7_9 extras
      dnf-automatic.noarch 4.0.9.2-2.el7_9 extras
      dnf-data.noarch 4.0.9.2-2.el7_9 extras
      dnf-langpacks.noarch 0.15.1-1.el7 epel
      dnf-langpacks-conf.noarch 0.15.1-1.el7 epel
      dnf-plugins-core.noarch 4.0.2.2-3.el7_6 extras
      [root@ansible ~]#
      [root@ansible ~]# yum install -y dnf
      (... 过多的输出)


      Installing : libcomps-0.1.8-14.el7.x86_64 7/11
      Installing : python2-libcomps-0.1.8-14.el7.x86_64 8/11
      Installing : dnf-data-4.0.9.2-2.el7_9.noarch 9/11
      Installing : python2-dnf-4.0.9.2-2.el7_9.noarch 10/11
      Installing : dnf-4.0.9.2-2.el7_9.noarch 11/11
      Verifying : python2-libcomps-0.1.8-14.el7.x86_64 1/11
      Verifying : dnf-4.0.9.2-2.el7_9.noarch 2/11
      Verifying : librepo-1.8.1-8.el7_9.x86_64 3/11
      Verifying : python2-hawkey-0.22.5-2.el7_9.x86_64 4/11
      Verifying : libmodulemd-1.6.3-1.el7.x86_64 5/11
      Verifying : dnf-data-4.0.9.2-2.el7_9.noarch 6/11
      Verifying : libdnf-0.22.5-2.el7_9.x86_64 7/11
      Verifying : python2-dnf-4.0.9.2-2.el7_9.noarch 8/11
      Verifying : libcomps-0.1.8-14.el7.x86_64 9/11
      Verifying : libsolv-0.6.34-4.el7.x86_64 10/11
      Verifying : python2-libdnf-0.22.5-2.el7_9.x86_64 11/11


      Installed:
      dnf.noarch 0:4.0.9.2-2.el7_9


      Dependency Installed:
      dnf-data.noarch 0:4.0.9.2-2.el7_9 libcomps.x86_64 0:0.1.8-14.el7
      libdnf.x86_64 0:0.22.5-2.el7_9 libmodulemd.x86_64 0:1.6.3-1.el7
      librepo.x86_64 0:1.8.1-8.el7_9 libsolv.x86_64 0:0.6.34-4.el7
      python2-dnf.noarch 0:4.0.9.2-2.el7_9 python2-hawkey.x86_64 0:0.22.5-2.el7_9
      python2-libcomps.x86_64 0:0.1.8-14.el7 python2-libdnf.x86_64 0:0.22.5-2.el7_9


      Complete!
      [root@ansible ~]#



      通过「rpm」命令,看看它到底装了些什么:

        [root@ansible ~]# rpm -qa | grep '^dnf'
        dnf-4.0.9.2-2.el7_9.noarch
        dnf-data-4.0.9.2-2.el7_9.noarch
        [root@ansible ~]#
        [root@ansible ~]# rpm -ql dnf
        /etc/bash_completion.d/dnf
        /usr/bin/dnf
        /usr/lib/systemd/system/dnf-makecache.service
        /usr/lib/systemd/system/dnf-makecache.timer
        /usr/share/locale/ar/LC_MESSAGES/dnf.mo
        /usr/share/locale/bg/LC_MESSAGES/dnf.mo
        /usr/share/locale/bn_IN/LC_MESSAGES/dnf.mo
        /usr/share/locale/ca/LC_MESSAGES/dnf.mo
        /usr/share/locale/cs/LC_MESSAGES/dnf.mo
        /usr/share/locale/da/LC_MESSAGES/dnf.mo
        /usr/share/locale/de/LC_MESSAGES/dnf.mo
        /usr/share/locale/el/LC_MESSAGES/dnf.mo
        /usr/share/locale/en_GB/LC_MESSAGES/dnf.mo
        /usr/share/locale/es/LC_MESSAGES/dnf.mo
        /usr/share/locale/eu/LC_MESSAGES/dnf.mo
        /usr/share/locale/fi/LC_MESSAGES/dnf.mo
        /usr/share/locale/fil/LC_MESSAGES/dnf.mo
        /usr/share/locale/fr/LC_MESSAGES/dnf.mo
        /usr/share/locale/fur/LC_MESSAGES/dnf.mo
        /usr/share/locale/gd/LC_MESSAGES/dnf.mo
        /usr/share/locale/gu/LC_MESSAGES/dnf.mo
        /usr/share/locale/he/LC_MESSAGES/dnf.mo
        /usr/share/locale/hi/LC_MESSAGES/dnf.mo
        /usr/share/locale/hr/LC_MESSAGES/dnf.mo
        /usr/share/locale/hu/LC_MESSAGES/dnf.mo
        /usr/share/locale/id/LC_MESSAGES/dnf.mo
        /usr/share/locale/it/LC_MESSAGES/dnf.mo
        /usr/share/locale/ja/LC_MESSAGES/dnf.mo
        /usr/share/locale/ka/LC_MESSAGES/dnf.mo
        /usr/share/locale/kk/LC_MESSAGES/dnf.mo
        /usr/share/locale/ko/LC_MESSAGES/dnf.mo
        /usr/share/locale/lt/LC_MESSAGES/dnf.mo
        /usr/share/locale/ml/LC_MESSAGES/dnf.mo
        /usr/share/locale/mr/LC_MESSAGES/dnf.mo
        /usr/share/locale/ms/LC_MESSAGES/dnf.mo
        /usr/share/locale/nb/LC_MESSAGES/dnf.mo
        /usr/share/locale/nl/LC_MESSAGES/dnf.mo
        /usr/share/locale/pa/LC_MESSAGES/dnf.mo
        /usr/share/locale/pl/LC_MESSAGES/dnf.mo
        /usr/share/locale/pt/LC_MESSAGES/dnf.mo
        /usr/share/locale/pt_BR/LC_MESSAGES/dnf.mo
        /usr/share/locale/ru/LC_MESSAGES/dnf.mo
        /usr/share/locale/sk/LC_MESSAGES/dnf.mo
        /usr/share/locale/sq/LC_MESSAGES/dnf.mo
        /usr/share/locale/sr/LC_MESSAGES/dnf.mo
        /usr/share/locale/sr@latin/LC_MESSAGES/dnf.mo
        /usr/share/locale/sv/LC_MESSAGES/dnf.mo
        /usr/share/locale/th/LC_MESSAGES/dnf.mo
        /usr/share/locale/tr/LC_MESSAGES/dnf.mo
        /usr/share/locale/uk/LC_MESSAGES/dnf.mo
        /usr/share/locale/ur/LC_MESSAGES/dnf.mo
        /usr/share/locale/zh_CN/LC_MESSAGES/dnf.mo
        /usr/share/locale/zh_TW/LC_MESSAGES/dnf.mo
        /usr/share/man/man8/dnf.8.gz
        /usr/share/man/man8/yum2dnf.8.gz
        /var/cache/dnf
        [root@ansible ~]#


        03

        DNF的使用

        查看版本信息:

          [root@ansible ~]# dnf --version
          4.0.9
          Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Thu 29 Aug 2024 08:09:47 AM CST
          Built : CentOS BuildSystem <http://bugs.centos.org> at Wed 07 Apr 2021 03:52:38 PM CST


          Installed: rpm-0:4.11.3-45.el7.x86_64 at Thu 29 Aug 2024 06:54:47 AM CST
          Built : CentOS BuildSystem <http://bugs.centos.org> at Wed 30 Sep 2020 05:30:03 PM CST
          [root@ansible ~]#


          查看帮助信息:

            [root@ansible ~]# dnf --help
            usage: dnf [options] COMMAND


            List of Main Commands:


            alias List or create command aliases
            autoremove remove all unneeded packages that were originally installed as dependencies
            check check for problems in the packagedb
            check-update check for available package upgrades
            clean remove cached data
            deplist List package's dependencies and what packages provide them
            distro-sync synchronize installed packages to the latest available versions
            downgrade Downgrade a package
            group display, or use, the groups information
            help display a helpful usage message
            history display, or use, the transaction history
            info display details about a package or group of packages
            install install a package or packages on your system
            list list a package or groups of packages
            makecache generate the metadata cache
            mark mark or unmark installed packages as installed by user.
            module Interact with Modules.
            provides find what package provides the given value
            reinstall reinstall a package
            remove remove a package or packages from your system
            repolist display the configured software repositories
            repoquery search for packages matching keyword
            repository-packages run commands on top of all packages in given repository
            search search package details for the given string
            shell run an interactive DNF shell
            swap run an interactive dnf mod for remove and install one spec
            updateinfo display advisories about packages
            upgrade upgrade a package or packages on your system
            upgrade-minimal upgrade, but only 'newest' package match which fixes a problem that affects your system


            Optional arguments:
            -c [config file], --config [config file]
            config file location
            -q, --quiet quiet operation
            -v, --verbose verbose operation
            --version show DNF version and exit
            --installroot [path] set install root
            --nodocs do not install documentations
            --noplugins disable all plugins
            --enableplugin [plugin]
            enable plugins by name
            --disableplugin [plugin]
            disable plugins by name
            --releasever RELEASEVER
            override the value of $releasever in config and repo
            files
            --setopt SETOPTS set arbitrary config and repo options
            --skip-broken resolve depsolve problems by skipping packages
            -h, --help, --help-cmd
            show command help
            --allowerasing allow erasing of installed packages to resolve
            dependencies
            -b, --best try the best available package versions in
            transactions.
            -C, --cacheonly run entirely from system cache, don't update cache
            -R [minutes], --randomwait [minutes]
            maximum command wait time
            -d [debug level], --debuglevel [debug level]
            debugging output level
            --debugsolver dumps detailed solving results into files
            --showduplicates show duplicates, in repos, in list/search commands
            -e ERRORLEVEL, --errorlevel ERRORLEVEL
            error output level
            --obsoletes enables dnf's obsoletes processing logic for upgrade
            or display capabilities that the package obsoletes for
            info, list and repoquery
            --rpmverbosity [debug level name]
            debugging output level for rpm
            -y, --assumeyes automatically answer yes for all questions
            --assumeno automatically answer no for all questions
            --enablerepo [repo]
            --disablerepo [repo]
            --repo [repo], --repoid [repo]
            enable just specific repositories by an id or a glob,
            can be specified multiple times
            --enable, --set-enabled
            enable repos with config-manager command
            (automatically saves)
            --disable, --set-disabled
            disable repos with config-manager command
            (automatically saves)
            -x [package], --exclude [package], --excludepkgs [package]
            exclude packages by name or glob
            --disableexcludes [repo], --disableexcludepkgs [repo]
            disable excludepkgs
            --repofrompath [repo,path]
            label and path to additional repository, can be
            specified multiple times.
            --noautoremove disable removal of dependencies that are no longer
            used
            --nogpgcheck disable gpg signature checking (if RPM policy allows)
            --color COLOR control whether color is used
            --refresh set metadata as expired before running the command
            -4 resolve to IPv4 addresses only
            -6 resolve to IPv6 addresses only
            --destdir DESTDIR, --downloaddir DESTDIR
            set directory to copy packages to
            --downloadonly only download packages
            --comment COMMENT add a comment to transaction
            --bugfix Include bugfix relevant packages, in updates
            --enhancement Include enhancement relevant packages, in updates
            --newpackage Include newpackage relevant packages, in updates
            --security Include security relevant packages, in updates
            --advisory ADVISORY, --advisories ADVISORY
            Include packages needed to fix the given advisory, in
            updates
            --bzs BUGZILLA Include packages needed to fix the given BZ, in
            updates
            --cves CVES Include packages needed to fix the given CVE, in
            updates
            --sec-severity {Critical,Important,Moderate,Low}, --secseverity {Critical,Important,Moderate,Low}
            Include security relevant packages matching the
            severity, in updates
            --forcearch ARCH Force the use of an architecture
            [root@ansible ~]#


            常用命令:

            install安装一个或多个软件包
            remove
            卸载一个或多个软件包
            update
            更新现有的软件包
            upgrade
            更新系统中所有的软件包(包括依赖项)
            info
            查询软件包详细信息
            search
            搜索软件包
            list
            列出系统中所有已安装的软件包
            clean
            清除系统中的缓存
            check-update
            检查系统中可用的更新
            repository
            管理YUM仓库
            module
            管理模块
            group
            管理软件包组
            config-manager
            管理 DNF 配置文件和库
            version
            查看 DNF 版本信息


            04

            查询软件库

            查询可用软件库:dnf repolist

            查询所有软件库:dnf repolist all


            具体如下:

              [root@ansible ~]# dnf repolist
              Extra Packages for Enterprise Linux 7 - x86_64 240 kB/s | 17 MB 01:13
              CentOS-7 - Base - mirrors.aliyun.com 214 kB/s | 10 MB 00:48
              CentOS-7 - Updates - mirrors.aliyun.com 287 kB/s | 34 MB 02:03
              CentOS-7 - Extras - mirrors.aliyun.com 54 kB/s | 361 kB 00:06
              Last metadata expiration check: 0:00:01 ago on Thu 29 Aug 2024 04:20:59 PM CST.
              repo id repo name status
              base CentOS-7 - Base - mirrors.aliyun.com 10,072
              epel Extra Packages for Enterprise Linux 7 - x86_64 13,791
              extras CentOS-7 - Extras - mirrors.aliyun.com 526
              updates CentOS-7 - Updates - mirrors.aliyun.com 6,173
              [root@ansible ~]#
              [root@ansible ~]# dnf repolist all
              Last metadata expiration check: 0:00:13 ago on Thu 29 Aug 2024 04:20:59 PM CST.
              repo id repo name status
              base CentOS-7 - Base - mirrors.aliyun.com enabled: 10,072
              centosplus CentOS-7 - Plus - mirrors.aliyun.com disabled
              contrib CentOS-7 - Contrib - mirrors.aliyun.com disabled
              epel Extra Packages for Enterprise Linux 7 - x86_64 enabled: 13,791
              epel-debuginfo Extra Packages for Enterprise Linux 7 - x86_64 - Debug disabled
              epel-source Extra Packages for Enterprise Linux 7 - x86_64 - Source disabled
              extras CentOS-7 - Extras - mirrors.aliyun.com enabled: 526
              updates CentOS-7 - Updates - mirrors.aliyun.com enabled: 6,173
              [root@ansible ~]#


              05

              查询系统的RPM包

              查询系统中所有的软件包:

                [root@ansible ~]# dnf list | head -n 30
                Last metadata expiration check: 0:00:46 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                Installed Packages
                GConf2.x86_64 3.2.6-8.el7 @System
                GeoIP.x86_64 1.5.0-14.el7 @System
                ModemManager.x86_64 1.6.10-4.el7 @System
                ModemManager-glib.x86_64 1.6.10-4.el7 @System
                NetworkManager.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-adsl.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-bluetooth.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-glib.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-libnm.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-libreswan.x86_64 1.2.4-2.el7 @System
                NetworkManager-libreswan-gnome.x86_64 1.2.4-2.el7 @System
                NetworkManager-ppp.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-team.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-tui.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-wifi.x86_64 1:1.18.8-1.el7 @System
                NetworkManager-wwan.x86_64 1:1.18.8-1.el7 @System
                PackageKit.x86_64 1.1.10-2.el7.centos @System
                PackageKit-command-not-found.x86_64 1.1.10-2.el7.centos @System
                PackageKit-glib.x86_64 1.1.10-2.el7.centos @System
                PackageKit-gstreamer-plugin.x86_64 1.1.10-2.el7.centos @System
                PackageKit-gtk3-module.x86_64 1.1.10-2.el7.centos @System
                PackageKit-yum.x86_64 1.1.10-2.el7.centos @System
                PyYAML.x86_64 3.10-11.el7 @System
                abattis-cantarell-fonts.noarch 0.0.25-1.el7 @System
                abrt.x86_64 2.1.11-60.el7.centos @System
                abrt-addon-ccpp.x86_64 2.1.11-60.el7.centos @System
                abrt-addon-kerneloops.x86_64 2.1.11-60.el7.centos @System
                abrt-addon-pstoreoops.x86_64 2.1.11-60.el7.centos @System
                [root@ansible ~]#


                查询已安装的RPM包:

                  [root@ansible ~]# dnf list installed | head -n 30
                  Installed Packages
                  GConf2.x86_64 3.2.6-8.el7 @System
                  GeoIP.x86_64 1.5.0-14.el7 @System
                  ModemManager.x86_64 1.6.10-4.el7 @System
                  ModemManager-glib.x86_64 1.6.10-4.el7 @System
                  NetworkManager.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-adsl.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-bluetooth.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-glib.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-libnm.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-libreswan.x86_64 1.2.4-2.el7 @System
                  NetworkManager-libreswan-gnome.x86_64 1.2.4-2.el7 @System
                  NetworkManager-ppp.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-team.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-tui.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-wifi.x86_64 1:1.18.8-1.el7 @System
                  NetworkManager-wwan.x86_64 1:1.18.8-1.el7 @System
                  PackageKit.x86_64 1.1.10-2.el7.centos @System
                  PackageKit-command-not-found.x86_64 1.1.10-2.el7.centos @System
                  PackageKit-glib.x86_64 1.1.10-2.el7.centos @System
                  PackageKit-gstreamer-plugin.x86_64 1.1.10-2.el7.centos @System
                  PackageKit-gtk3-module.x86_64 1.1.10-2.el7.centos @System
                  PackageKit-yum.x86_64 1.1.10-2.el7.centos @System
                  PyYAML.x86_64 3.10-11.el7 @System
                  abattis-cantarell-fonts.noarch 0.0.25-1.el7 @System
                  abrt.x86_64 2.1.11-60.el7.centos @System
                  abrt-addon-ccpp.x86_64 2.1.11-60.el7.centos @System
                  abrt-addon-kerneloops.x86_64 2.1.11-60.el7.centos @System
                  abrt-addon-pstoreoops.x86_64 2.1.11-60.el7.centos @System
                  abrt-addon-python.x86_64 2.1.11-60.el7.centos @System
                  [root@ansible ~]#


                  查询可供安装的RPM包:

                    [root@ansible ~]# dnf list available | head -n 30
                    Last metadata expiration check: 0:02:49 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                    Available Packages
                    0ad.x86_64 0.0.22-1.el7 epel
                    0ad-data.noarch 0.0.22-1.el7 epel
                    0install.x86_64 2.11-1.el7 epel
                    2048-cli.x86_64 0.9.1-1.el7 epel
                    2048-cli-nocurses.x86_64 0.9.1-1.el7 epel
                    2ping.noarch 3.2.1-2.el7 epel
                    389-ds-base.src 1.3.11.1-5.el7_9 updates
                    389-ds-base.x86_64 1.3.11.1-5.el7_9 updates
                    389-ds-base-devel.x86_64 1.3.11.1-5.el7_9 updates
                    389-ds-base-libs.x86_64 1.3.11.1-5.el7_9 updates
                    389-ds-base-snmp.x86_64 1.3.11.1-5.el7_9 updates
                    3proxy.x86_64 0.9.4-2.el7 epel
                    4diac-forte.x86_64 1.9.0-0.1.M3.el7 epel
                    90-Second-Portraits.noarch 1.01b-3.el7 epel
                    AMF-devel.noarch 1.4.30-1.el7 epel
                    AMF-samples.noarch 1.4.30-1.el7 epel
                    Agda.x86_64 2.3.2.2-5.el7 epel
                    AntTweakBar.x86_64 1.16-2.el7 epel
                    AntTweakBar-devel.x86_64 1.16-2.el7 epel
                    AusweisApp2.x86_64 1.14.3-2.el7 epel
                    AusweisApp2-data.noarch 1.14.3-2.el7 epel
                    AusweisApp2-doc.noarch 1.14.3-2.el7 epel
                    BEDTools.x86_64 2.26.0-1.el7 epel
                    BackupPC.x86_64 3.3.1-5.el7 epel
                    BackupPC-XS.x86_64 0.59-1.el7 epel
                    BareBonesBrowserLaunch.noarch 3.1-7.el7 epel
                    BareBonesBrowserLaunch-javadoc.noarch 3.1-7.el7 epel
                    BibTool.x86_64 2.63-1.el7 epel
                    [root@ansible ~]#


                    查询某个软件包:

                      [root@ansible ~]# dnf search ansible
                      Last metadata expiration check: 0:03:33 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                      ===================================== Name Exactly Matched: ansible ======================================
                      ansible.noarch : SSH-based configuration management, deployment, and task execution system
                      ==================================== Name & Summary Matched: ansible =====================================
                      ansible-doc.noarch : Documentation for Ansible
                      ansible-lint.noarch : Best practices checker for Ansible
                      python2-ansible-tower-cli.noarch : A CLI tool for Ansible Tower
                      ansible-test.noarch : Tool for testing ansible plugin and module code
                      ansible-inventory-grapher.noarch : Creates graphs representing ansible inventory
                      vim-ansible.noarch : Vim plugin for syntax highlighting ansible's common filetypes
                      python2-ansible-runner.noarch : A tool and python library to interface with Ansible
                      ansible-openstack-modules.noarch : Unofficial Ansible modules for managing Openstack
                      ansible-review.noarch : Reviews Ansible playbooks, roles and inventory and suggests improvements
                      ansible-collection-microsoft-sql.noarch : The Ansible collection for Microsoft SQL Server management
                      centos-release-ansible26.noarch : Ansible 2.6 packages from the CentOS ConfigManagement SIG repository
                      centos-release-ansible-27.noarch : Ansible 2.7 packages from the CentOS ConfigManagement SIG repository
                      centos-release-ansible-28.noarch : Ansible 2.8 packages from the CentOS ConfigManagement SIG repository
                      centos-release-ansible-29.noarch : Ansible 2.9 packages from the CentOS ConfigManagement SIG repository
                      ========================================= Name Matched: ansible ==========================================
                      ansible-python3.noarch : SSH-based configuration management, deployment, and task execution system
                      kubernetes-ansible.noarch : Playbook and set of roles for seting up a Kubernetes cluster onto machines
                      ======================================== Summary Matched: ansible ========================================
                      scap-security-guide-rule-playbooks.noarch : Ansible playbooks per each rule.
                      standard-test-roles.noarch : Standard Test Interface Ansible roles
                      loopabull.noarch : Event loop driven Ansible playbook execution engine
                      paternoster.noarch : Allows to run ansible playbooks like ordinary python or bash scripts
                      [root@ansible ~]#


                      查询某个命令所对应的软件包:

                        [root@ansible ~]# dnf provides bin/bash
                        Last metadata expiration check: 0:04:27 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                        bash-4.2.46-34.el7.x86_64 : The GNU Bourne Again shell
                        Repo : @System
                        Matched from:
                        Provide : bin/bash


                        bash-4.2.46-34.el7.x86_64 : The GNU Bourne Again shell
                        Repo : base
                        Matched from:
                        Provide : bin/bash


                        bash-4.2.46-35.el7_9.x86_64 : The GNU Bourne Again shell
                        Repo : updates
                        Matched from:
                        Provide : bin/bash


                        [root@ansible ~]#


                        06

                        安装与卸载


                        安装:

                          [root@ansible ~]# dnf install -y tree
                          Last metadata expiration check: 0:05:00 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                          Dependencies resolved.
                          ==========================================================================================================
                          Package Arch Version Repository Size
                          ==========================================================================================================
                          Installing:
                          tree x86_64 1.6.0-10.el7 base 46 k


                          Transaction Summary
                          ==========================================================================================================
                          Install 1 Package


                          Total download size: 46 k
                          Installed size: 87 k
                          Downloading Packages:
                          tree-1.6.0-10.el7.x86_64.rpm 8.4 kB/s | 46 kB 00:05
                          ----------------------------------------------------------------------------------------------------------
                          Total 8.4 kB/s | 46 kB 00:05
                          Running transaction check
                          Transaction check succeeded.
                          Running transaction test
                          Transaction test succeeded.
                          Running transaction
                          Preparing : 1/1
                          Installing : tree-1.6.0-10.el7.x86_64 1/1
                          Verifying : tree-1.6.0-10.el7.x86_64 1/1


                          Installed:
                          tree-1.6.0-10.el7.x86_64


                          Complete!
                          [root@ansible ~]#


                          卸载:

                            [root@ansible ~]# dnf remove -y tree
                            Dependencies resolved.
                            ==========================================================================================================
                            Package Arch Version Repository Size
                            ==========================================================================================================
                            Removing:
                            tree x86_64 1.6.0-10.el7 @base 87 k


                            Transaction Summary
                            ==========================================================================================================
                            Remove 1 Package


                            Freed space: 87 k
                            Running transaction check
                            Transaction check succeeded.
                            Running transaction test
                            Transaction test succeeded.
                            Running transaction
                            Preparing : 1/1
                            Erasing : tree-1.6.0-10.el7.x86_64 1/1
                            Verifying : tree-1.6.0-10.el7.x86_64 1/1


                            Removed:
                            tree-1.6.0-10.el7.x86_64


                            Complete!
                            [root@ansible ~]#


                            更新软件包:

                              [root@ansible ~]# dnf update -y tree
                              Last metadata expiration check: 0:07:22 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                              Dependencies resolved.
                              Nothing to do.
                              Complete!
                              [root@ansible ~]#


                              检查系统软件包的更新:

                                [root@ansible ~]# dnf check-update | head -n 10
                                Last metadata expiration check: 0:08:20 ago on Thu 29 Aug 2024 04:20:59 PM CST.


                                NetworkManager.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-adsl.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-bluetooth.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-glib.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-libnm.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-ppp.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-team.x86_64 1:1.18.8-2.el7_9 updates
                                NetworkManager-tui.x86_64 1:1.18.8-2.el7_9 updates
                                [root@ansible ~]#


                                升级所有系统软件包:

                                  dnf update
                                  dnf upgrade


                                  07

                                  DNF的命令执行历史


                                  具体如下:

                                    [root@ansible ~]# dnf history
                                    ID | Command line | Date and time | Action(s) | Altered
                                    -------------------------------------------------------------------------------
                                    4 | install ansible-python3 | 2024-08-29 16:29 | Install | 19
                                    3 | install -y tree | 2024-08-29 16:27 | Install | 1
                                    2 | remove -y tree | 2024-08-29 16:26 | Removed | 1
                                    1 | install -y tree | 2024-08-29 16:26 | Install | 1
                                    [root@ansible ~]#


                                    08

                                    软件包组


                                    查看所有的软件包组:

                                      [root@ansible ~]# dnf grouplist
                                      Last metadata expiration check: 0:11:11 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                                      Available Environment Groups:
                                      Minimal Install
                                      Compute Node
                                      Infrastructure Server
                                      File and Print Server
                                      Cinnamon Desktop
                                      MATE Desktop
                                      Basic Web Server
                                      Virtualization Host
                                      Server with GUI
                                      GNOME Desktop
                                      KDE Plasma Workspaces
                                      Development and Creative Workstation
                                      Available Groups:
                                      Cinnamon
                                      Educational Software
                                      Electronic Lab
                                      Fedora Packager
                                      General Purpose Desktop
                                      Haskell
                                      LXQt Desktop
                                      MATE
                                      Milkymist
                                      TurboGears application framework
                                      Xfce
                                      Compatibility Libraries
                                      Console Internet Tools
                                      Development Tools
                                      Graphical Administration Tools
                                      Legacy UNIX Compatibility
                                      Scientific Support
                                      Security Tools
                                      Smart Card Support
                                      System Administration Tools
                                      System Management
                                      [root@ansible ~]#


                                      安装其中某一个软件包组:

                                        dnf groupinstall "System Management


                                        09

                                        软件包


                                        查询软件包的详细信息:

                                          [root@ansible ~]# dnf info ansible-python3
                                          Last metadata expiration check: 0:13:10 ago on Thu 29 Aug 2024 04:20:59 PM CST.
                                          Installed Packages
                                          Name : ansible-python3
                                          Version : 2.9.27
                                          Release : 1.el7
                                          Arch : noarch
                                          Size : 141 M
                                          Source : ansible-2.9.27-1.el7.src.rpm
                                          Repo : @System
                                          From repo : epel
                                          Summary : SSH-based configuration management, deployment, and task execution system
                                          URL : http://ansible.com
                                          License : GPLv3+
                                          Description :
                                          :
                                          :
                                          :
                                          : Ansible is a radically simple model-driven configuration management,
                                          : multi-node deployment, and remote task execution system. Ansible works
                                          : over SSH and does not require any software or daemons to be installed
                                          : on remote nodes. Extension modules can be written in any language and
                                          : are transferred to managed machines automatically.
                                          :
                                          : This package installs versions of ansible that execute on Python3.


                                          [root@ansible ~]#





                                          END




                                          温馨提示



                                          如果你喜欢本文,请分享到朋友圈,想要获得更多信息,请关注我。


                                          文章转载自Nephilim,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                          评论