centos安装yum命令

发布时间: 2023-11-21 10:46 阅读: 文章来源:1MUMB114PS

以下展示Centos7 和Centos8 两种系统方式。

2.3 yum命令yum命令的用法yum [options] [command] [package ...]yum的命令行选项-y#自动回答为“yes”-q#静默模式--nogpgcheck #禁止进行gpg check--enablerepo=repoidglob#临时启用此处指定的repo,支持通配符,如:”*“--disablerepo=repoidglob#临时禁用此处指定的repo,和上面语句同时使用,放在后面的生效2.3.1 显示仓库列表yum repolist [all|enabled|disabled]范例[root@centos8 ~]#yum repolist[root@centos8 ~]#yum repolist allLast metadata expiration check: 0:01:32 ago on Sun 29 Dec 2019 12:13:10 AM CST.repo id repo name statusAppStreamAppStream enabled: 4,681BaseOSBaseOSenabled: 1,655epelEPELdisabledextrasextrasdisabled[root@centos8 ~]#yum --enablerepo=ep* --disablerepo=A* repolistLast metadata expiration check: 0:01:18 ago on Sun 29 Dec 2019 12:13:27 AM CST.repo idrepo name statusBaseOSBaseOS1,657epel EPEL3,733---------------[root@cent7 ~]#yum repolistLoaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comrepo id repo namestatusbase/7/x86_64CentOS-7 - Base10,072epelepel13,606extras/7/x86_64 CentOS-7 - Extras 476updates/7/x86_64CentOS-7 - Updates2,189repolist: 26,343[root@cent7 ~]#yum repolist allLoaded plugins: fastestmirror * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comrepo id repo name statusC7.0.1406-base/x86_64CentOS-7.0.1406 - Bas disabledC7.0.1406-centosplus/x86_64 CentOS-7.0.1406 - Cen disabledC7.0.1406-extras/x86_64 CentOS-7.0.1406 - Ext disabledC7.0.1406-fasttrack/x86_64CentOS-7.0.1406 - Fas disabledC7.0.1406-updates/x86_64CentOS-7.0.1406 - Upd disabledC7.1.1503-base/x86_64CentOS-7.1.1503 - Bas disabledC7.1.1503-centosplus/x86_64 CentOS-7.1.1503 - Cen disabledC7.1.1503-extras/x86_64 CentOS-7.1.1503 - Ext disabledC7.1.1503-fasttrack/x86_64CentOS-7.1.1503 - Fas disabledC7.1.1503-updates/x86_64CentOS-7.1.1503 - Upd disabledC7.2.1511-base/x86_64CentOS-7.2.1511 - Bas disabledC7.2.1511-centosplus/x86_64 CentOS-7.2.1511 - Cen disabledC7.2.1511-extras/x86_64 CentOS-7.2.1511 - Ext disabledC7.2.1511-fasttrack/x86_64CentOS-7.2.1511 - Fas disabledC7.2.1511-updates/x86_64CentOS-7.2.1511 - Upd disabledC7.3.1611-base/x86_64CentOS-7.3.1611 - Bas disabledC7.3.1611-centosplus/x86_64 CentOS-7.3.1611 - Cen disabledC7.3.1611-extras/x86_64 CentOS-7.3.1611 - Ext disabledC7.3.1611-fasttrack/x86_64CentOS-7.3.1611 - Fas disabledC7.3.1611-updates/x86_64CentOS-7.3.1611 - Upd disabledC7.4.1708-base/x86_64CentOS-7.4.1708 - Bas disabledC7.4.1708-centosplus/x86_64 CentOS-7.4.1708 - Cen disabledC7.4.1708-extras/x86_64 CentOS-7.4.1708 - Ext disabledC7.4.1708-fasttrack/x86_64CentOS-7.4.1708 - Fas disabledC7.4.1708-updates/x86_64CentOS-7.4.1708 - Upd disabledC7.5.1804-base/x86_64CentOS-7.5.1804 - Bas disabledC7.5.1804-centosplus/x86_64 CentOS-7.5.1804 - Cen disabledC7.5.1804-extras/x86_64 CentOS-7.5.1804 - Ext disabledC7.5.1804-fasttrack/x86_64CentOS-7.5.1804 - Fas disabledC7.5.1804-updates/x86_64CentOS-7.5.1804 - Upd disabledC7.6.1810-base/x86_64CentOS-7.6.1810 - Bas disabledC7.6.1810-centosplus/x86_64 CentOS-7.6.1810 - Cen disabledC7.6.1810-extras/x86_64 CentOS-7.6.1810 - Ext disabledC7.6.1810-fasttrack/x86_64CentOS-7.6.1810 - Fas disabledC7.6.1810-updates/x86_64CentOS-7.6.1810 - Upd disabledC7.7.1908-base/x86_64CentOS-7.7.1908 - Bas disabledC7.7.1908-centosplus/x86_64 CentOS-7.7.1908 - Cen disabledC7.7.1908-extras/x86_64 CentOS-7.7.1908 - Ext disabledC7.7.1908-fasttrack/x86_64CentOS-7.7.1908 - Fas disabledC7.7.1908-updates/x86_64CentOS-7.7.1908 - Upd disabledbase/7/x86_64CentOS-7 - Baseenabled: 10,072base-debuginfo/x86_64CentOS-7 - Debuginfodisabledbase-source/7CentOS-7 - Base Sourc disabledc7-mediaCentOS-7 - Mediadisabledcentos-kernel/7/x86_64CentOS LTS Kernels fo disabledcentos-kernel-experimental/7/x86_64 CentOS Experimental K disabledcentosplus/7/x86_64 CentOS-7 - Plusdisabledcentosplus-source/7 CentOS-7 - Plus Sourc disabledcontrib/7/x86_64Contribdisabledcr/7/x86_64 CentOS-7 - cr disabledepelepelenabled: 13,606extras/7/x86_64 CentOS-7 - Extras enabled:476extras-source/7 CentOS-7 - Extras Sou disabledfasttrack/7/x86_64CentOS-7 - fasttrackdisabledupdates/7/x86_64CentOS-7 - Updatesenabled:2,189updates-source/7CentOS-7 - Updates So disabledrepolist: 26,343范例: 显示仓库的详细信息[root@cent7 ~]#yum repolist -vLoading "fastestmirror" pluginConfig time: 0.007Yum version: 3.4.3Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comSetting up Package Sackspkgsack time: 0.010Repo-id: base/7/x86_64Repo-name: CentOS-7 - BaseRepo-revision: 1604001756Repo-updated : Fri Oct 30 04:03:00 2020Repo-pkgs: 10,072Repo-size: 8.9 GRepo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stockRepo-baseurl : http://mirrors.cn99.com/centos/7.9.2009/os/x86_64/ (9 : more)Repo-expire: 21,600 second(s) (last: Sat Jun5 21:46:53 2021)Filter : read-only:presentRepo-filename: /etc/yum.repos.d/CentOS-Base.repoRepo-id: epelRepo-name: epelRepo-revision: 1622855949Repo-updated : Sat Jun5 09:22:11 2021Repo-pkgs: 13,606Repo-size: 16 GRepo-baseurl : http://mirrors.aliyun.com/epel/7/x86_64/Repo-expire: 21,600 second(s) (last: Sat Jun5 21:46:53 2021)Filter : read-only:presentRepo-filename: /etc/yum.repos.d/base.repoRepo-id: extras/7/x86_64Repo-name: CentOS-7 - ExtrasRepo-revision: 1619708467Repo-updated : Thu Apr 29 23:01:09 2021Repo-pkgs: 476Repo-size: 862 MRepo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stockRepo-baseurl : http://mirrors.cn99.com/centos/7.9.2009/extras/x86_64/ (9 : more)Repo-expire: 21,600 second(s) (last: Sat Jun5 21:46:53 2021)Filter : read-only:presentRepo-filename: /etc/yum.repos.d/CentOS-Base.repoRepo-id: updates/7/x86_64Repo-name: CentOS-7 - UpdatesRepo-revision: 1620705296Repo-updated : Tue May 11 11:55:19 2021Repo-pkgs: 2,189Repo-size: 12 GRepo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stockRepo-baseurl : http://mirrors.cn99.com/centos/7.9.2009/updates/x86_64/ (9 : more)Repo-expire: 21,600 second(s) (last: Sat Jun5 21:46:54 2021)Filter : read-only:presentRepo-filename: /etc/yum.repos.d/CentOS-Base.reporepolist: 26,343-------------------------------------------[root@centos8 ~]#yum repolist -vLoaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground,repoclosure, repodiff, repograph, repomanage, reposyncYUM version: 4.2.17cachedir: /var/cache/dnfUser-Agent: constructed: ‘libdnf (CentOS Linux 8; generic; Linux.x86_64)‘repo: downloading from remote: BaseOSBaseOS: using metadata from Tue 09 Jun 2020 06:06:00 AM CST.repo: downloading from remote: AppStreamAppStream: using metadata from Tue 09 Jun 2020 06:06:04 AM CST.repo: downloading from remote: epelepel: using metadata from Fri 03 Jul 2020 08:21:13 AM CST.repo: downloading from remote: extrasextras: using metadata from Fri 05 Jun 2020 08:15:26 AM CST.Last metadata expiration check: 0:00:01 ago on Sat 04 Jul 2020 12:17:23 PM CST.Completion plugin: Generating completion cache...Repo-id: AppStreamRepo-name : AppStreamRepo-revision: 8.2.2004Repo-distro-tags: [cpe:/o:centos:centos:8]: , 8, C, O, S, e, n, tRepo-updated: Tue 09 Jun 2020 06:06:04 AM CSTRepo-pkgs : 5,326Repo-available-pkgs: 4,901Repo-size : 6.0 GRepo-baseurl: file:///misc/cd/AppStream,https://mirrors.aliyun.com/centos/8/AppStream/x86_64/os/Repo-expire: 172,800 second(s) (last: Sat 04 Jul 2020 12:17:20 PM CST)Repo-filename: /etc/yum.repos.d/base.repoRepo-id: BaseOSRepo-name : BaseOSRepo-revision: 8.2.2004Repo-distro-tags: [cpe:/o:centos:centos:8]: , 8, C, O, S, e, n, tRepo-updated: Tue 09 Jun 2020 06:06:00 AM CSTRepo-pkgs : 1,674Repo-available-pkgs: 1,672Repo-size : 1.0 GRepo-baseurl: file:///misc/cd/BaseOS,https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/Repo-expire: 172,800 second(s) (last: Sat 04 Jul 2020 12:17:19 PM CST)Repo-filename: /etc/yum.repos.d/base.repoRepo-id: epelRepo-name : EPELRepo-revision: 1593735642Repo-updated: Fri 03 Jul 2020 08:21:13 AM CSTRepo-pkgs : 5,931Repo-available-pkgs: 5,930Repo-size : 7.7 GRepo-baseurl: https://mirrors.aliyun.com/epel/8/Everything/x86_64Repo-expire: 172,800 second(s) (last: Sat 04 Jul 2020 12:17:21 PM CST)Repo-filename: /etc/yum.repos.d/base.repoRepo-id: extrasRepo-name : extrasRepo-revision: 1591316131Repo-updated: Fri 05 Jun 2020 08:15:26 AM CSTRepo-pkgs : 20Repo-available-pkgs: 20Repo-size : 236 kRepo-baseurl: https://mirrors.aliyun.com/centos/8/extras/x86_64/osRepo-expire: 172,800 second(s) (last: Sat 04 Jul 2020 12:17:23 PM CST)Repo-filename: /etc/yum.repos.d/base.repoTotal packages: 12,9512.3.2 显示程序包yum listyum list [all | glob_exp1] [glob_exp2] [...]yum list {available|installed|updates} [glob_exp1] [...]范例[root@centos8 data]#dnf list mariadb-serverLast metadata expiration check: 0:05:03 ago on Sun 08 Dec 2019 04:11:17 PM CST.Available Packagesmariadb-server.x86_643:10.3.11-2.module_el8.0.0+35+6f2527edAppStream[root@centos8 data]#dnf list mariadb-server --showduplicates Last metadata expiration check: 0:05:11 ago on Sun 08 Dec 2019 04:11:17 PM CST.Available Packagesmariadb-server.x86_643:10.3.11-2.module_el8.0.0+35+6f2527edAppStream[root@centos8 data]#dnf list mariadb-server--disablerepo=AppStreamLast metadata expiration check: 0:05:23 ago on Sun 08 Dec 2019 04:11:17 PM CST.Available PackagesMariaDB-server.x86_6410.4.10-1.el8mariadb2[root@centos8 data]#dnf list mariadb-server --showduplicates --disablerepo=AppStreamLast metadata expiration check: 0:05:41 ago on Sun 08 Dec 2019 04:11:17 PM CST.Available PackagesMariaDB-server.x86_6410.3.17-1.el8mariadbMariaDB-server.x86_6410.3.18-1.el8mariadbMariaDB-server.x86_6410.3.20-1.el8mariadbMariaDB-server.x86_6410.4.7-1.el8mariadb2MariaDB-server.x86_6410.4.8-1.el8mariadb2MariaDB-server.x86_6410.4.10-1.el8mariadb2[root@centos8 ~]#yum --disablerepo="A*" --disablerepo="B*" --disablerepo="e*" list available-----------------------------------------------------------------[root@cent7 ~]#yumlist mariadb-serverLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comAvailable Packagesmariadb-server.x86_64 1:5.5.68-1.el7 base[root@cent7 ~]#yum list mariadb-server --showduplicates Loaded plugins: fastestmirror * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comAvailable Packagesmariadb-server.x86_64 1:5.5.68-1.el7 base范例: 只查看已经安装的包[root@centos8 ~]#yum list installed|headInstalled PackagesNetworkManager.x86_641:1.22.8-4.el8@anacondaNetworkManager-libnm.x86_64 1:1.22.8-4.el8@anacondaNetworkManager-team.x86_641:1.22.8-4.el8@anacondaNetworkManager-tui.x86_641:1.22.8-4.el8@anacondaacl.x86_642.2.53-1.el8@anacondaat.x86_643.1.20-11.el8@BaseOS audit.x86_64 3.0-0.17.20191104git1c2f876.el8@anacondaaudit-libs.x86_643.0-0.17.20191104git1c2f876.el8@anacondaauthselect.x86_641.1-2.el8@anaconda----------------------------------------------------------[root@cent7 ~]#yum list installed |head -6Loaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationInstalled PackagesGConf2.x86_643.2.6-8.el7@baseGeoIP.x86_641.5.0-14.el7@baseNetworkManager.x86_641:1.18.4-3.el7 @anacondaNetworkManager-libnm.x86_64 1:1.18.4-3.el7 @anacondaExiting on Broken Pipe范例: 查看可安装的包[root@centos8 ~]#yum list available |headAvailable Packages3proxy.x86_640.8.13-1.el8epelBackupPC.x86_644.4.0-1.el8epelBackupPC-XS.x86_640.62-1.el8epelBibTool.x86_64 2.68-1.el8 epelCCfits.x86_642.5-13.el8 epelCCfits-devel.x86_642.5-13.el8epelCCfits-doc.noarch 2.5-13.el8epelCGSI-gSOAP.x86_641.3.11-7.el8 epel-----------------------------------------------[root@cent7 ~]#yum list available |headLoaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comAvailable Packages0ad.x86_640.0.22-1.el7epel0ad-data.noarch0.0.22-1.el7epel0install.x86_642.11-1.el7 epel2048-cli.x86_640.9.1-1.el7epelExiting on Broken Pipe范例: 查看可以升级的包[root@centos8 ~]#yum list updatesLast metadata expiration check: 2:16:44 ago on Sun 26 Jun 2021 10:28:24 AM CST.Available Upgradesexim.x86_64---------------------------------------------[root@cent7 ~]#yum list updatesLoaded plugins: fastestmirror * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comUpdated PackagesNetworkManager.x86_641:1.18.8-2.el7_9updatesNetworkManager-libnm.x86_641:1.18.8-2.el7_9updatesNetworkManager-team.x86_64 1:1.18.8-2.el7_9updatesNetworkManager-tui.x86_641:1.18.8-2.el7_9updatesNetworkManager-wifi.x86_64 1:1.18.8-2.el7_9updatesbind-export-libs.x86_6432:9.11.4-26.P2.el7_9.5updatesbinutils.x86_642.27-44.base.el7baseca-certificates.noarch 2020.2.41-70.0.el7_8basecentos-release.x86_647-9.2009.1.el7.centosupdateschkconfig.x86_641.7.6-1.el7basecoreutils.x86_648.22-24.el7_9.2updatescpio.x86_642.11-28.el7basecurl.x86_647.29.0-59.el7_9.1updatesdbus.x86_641:1.10.24-15.el7basedbus-libs.x86_641:1.10.24-15.el7basedevice-mapper.x86_647:1.02.170-6.el7_9.5updatesdevice-mapper-libs.x86_647:1.02.170-6.el7_9.5updatesdhclient.x86_6412:4.2.5-82.el7.centos basedhcp-common.x86_64 12:4.2.5-82.el7.centos basedhcp-libs.x86_6412:4.2.5-82.el7.centos basedmidecode.x86_641:3.2-5.el7_9.1updatesdracut.x86_64033-572.el7basedracut-config-rescue.x86_64033-572.el7basedracut-network.x86_64033-572.el7basee2fsprogs.x86_641.42.9-19.el7basee2fsprogs-libs.x86_641.42.9-19.el7baseelfutils-default-yama-scope.noarch 0.176-5.el7baseelfutils-libelf.x86_64 0.176-5.el7baseelfutils-libs.x86_640.176-5.el7baseexpat.x86_642.1.0-12.el7basefile.x86_645.11-37.el7basefile-libs.x86_645.11-37.el7basefirewalld.noarch0.6.3-13.el7_9 updatesfirewalld-filesystem.noarch0.6.3-13.el7_9 updatesfreetype.x86_642.8-14.el7_9.1 updatesglib2.x86_642.56.1-8.el7updatesglibc.x86_642.17-324.el7_9 updatesglibc-common.x86_642.17-324.el7_9 updatesgrub2.x86_641:2.02-0.87.el7.centos.6updatesgrub2-common.noarch1:2.02-0.87.el7.centos.6updates范例: 查看指定的包[root@centos8 ~]#yum list eximLast metadata expiration check: 2:15:35 ago on Sun 26 Jul 2020 10:28:24 AM CST.Installed Packagesexim.x86_644.93-3.el8 @epelAvailable Packagesexim.x86_644.94-1.el8 epel#支持通配符[root@centos8 ~]#yum list exim*Last metadata expiration check: 2:15:47 ago on Sun 26 Jul 2020 10:28:24 AM CST.Installed Packagesexim.x86_644.93-3.el8@epelAvailable Packagesexim.x86_644.94-1.el8epelexim-greylist.x86_644.94-1.el8 epelexim-mon.x86_644.94-1.el8epelexim-mysql.x86_64 4.94-1.el8epel--------------------------------------------------------------------[root@cent7 ~]#yum list eximLoaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comAvailable Packagesexim.x86_644.94.2-1.el7epe[root@cent7 ~]#yum list exim*Loaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comAvailable Packagesexim.x86_644.94.2-1.el7epelexim-greylist.x86_644.94.2-1.el7epelexim-mon.x86_644.94.2-1.el7epelexim-mysql.x86_64 4.94.2-1.el7epelexim-pgsql.x86_64 4.94.2-1.el7epelexim-sysvinit.noarch4.94.2-1.el7epe2.3.3 安装程序包yum install package1 [package2] [...]yum reinstall package1 [package2] [...]#重新安装--downloadonly #只下载相关包默认至/var/cache/yum/x86_64/7/目录下,而不执行install/upgrade/erase--downloaddir=, --destdir=#--downloadonly选项来指定下载的目录,如果不存在自动创建2.3.3.1 安装epel源包#yum -y install epel-release#yum -y install sl#rpm -ql sl/usr/bin/sl/usr/share/doc/sl-5.02/usr/share/doc/sl-5.02/LICENSE/usr/share/doc/sl-5.02/README.ja.md/usr/share/doc/sl-5.02/README.md/usr/share/man/ja/man1/sl.1.ja.gz/usr/share/man/man1/sl.1.gz#运行安装sl程序,可以看到下面火车#sl -a

#yum -y install cowsay

2.3.3.2 升级最新内核范例: 利用elrepo源在centos7安装最新版内核

说明: The difference is that kernel-lt is based on a long term support branch and kernel-ml is based on the mainline stable branch.

[root@centos7 ~]#yum install https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm[root@centos7 ~]#rpm -ql elrepo-release-7.0-4.el7.elrepo/etc/pki/elrepo/etc/pki/elrepo/SECURE-BOOT-KEY-elrepo.org.der/etc/pki/rpm-gpg/etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org/etc/yum.repos.d/etc/yum.repos.d/elrepo.repo[root@centos7 ~]#yum repolistyum repolistLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile* elrepo: mirrors.tuna.tsinghua.edu.cnrepo id repo namestatusbaseCentOS 10,019elrepo ELRepo.org Community Enterprise Linux Repository- el7 139epel/7/x86_64EPEL13,501extras/7/x86_64 extras307repolist: 23,966[root@centos7 ~]#cat /etc/yum.repos.d/elrepo.repo### Name: ELRepo.org Community Enterprise Linux Repository for el7### URL: http://elrepo.org/[elrepo]name=ELRepo.org Community Enterprise Linux Repository - el7baseurl=http://elrepo.org/linux/elrepo/el7/$basearch/http://mirrors.coreix.net/elrepo/elrepo/el7/$basearch/http://mirror.rackspace.com/elrepo/elrepo/el7/$basearch/http://repos.lax-noc.com/elrepo/elrepo/el7/$basearch/mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el7enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.orgprotect=0[elrepo-testing]name=ELRepo.org Community Enterprise Linux Testing Repository - el7baseurl=http://elrepo.org/linux/testing/el7/$basearch/http://mirrors.coreix.net/elrepo/testing/el7/$basearch/http://mirror.rackspace.com/elrepo/testing/el7/$basearch/http://repos.lax-noc.com/elrepo/testing/el7/$basearch/mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el7enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.orgprotect=0[elrepo-kernel]name=ELRepo.org Community Enterprise Linux Kernel Repository - el7baseurl=http://elrepo.org/linux/kernel/el7/$basearch/http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/http://repos.lax-noc.com/elrepo/kernel/el7/$basearch/mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.orgprotect=0[elrepo-extras]name=ELRepo.org Community Enterprise Linux Extras Repository - el7baseurl=http://elrepo.org/linux/extras/el7/$basearch/http://mirrors.coreix.net/elrepo/extras/el7/$basearch/http://mirror.rackspace.com/elrepo/extras/el7/$basearch/http://repos.lax-noc.com/elrepo/extras/el7/$basearch/mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el7enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.orgprotect=0[root@centos7 ~]#yum --disablerepo="*" --enablerepo="elrepo-kernel" listavailableLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile* elrepo-kernel: mirrors.tuna.tsinghua.edu.cnAvailable Packageskernel-lt.x86_644.4.207-1.el7.elrepoelrepo-kernelkernel-lt-devel.x86_644.4.207-1.el7.elrepoelrepo-kernelkernel-lt-doc.noarch4.4.207-1.el7.elrepoelrepo-kernelkernel-lt-headers.x86_644.4.207-1.el7.elrepoelrepo-kernelkernel-lt-tools.x86_644.4.207-1.el7.elrepoelrepo-kernel .....#yum -y --enablerepo="elrepo-kernel" install kernel-ml#ls /bootconfig-3.10.0-957.el7.x86_64symvers-3.10.0-957.el7.x86_64.gzconfig-5.4.6-1.el7.elrepo.x86_64symvers-5.4.6-1.el7.elrepo.x86_64.gzefiSystem.map-3.10.0-957.el7.x86_64grub System.map-5.4.6-1.el7.elrepo.x86_64grub2vmlinuz-0-rescue-907ef8572fc24762bcbaac846dd46fccinitramfs-0-rescue-907ef8572fc24762bcbaac846dd46fcc.img vmlinuz-3.10.0-957.el7.x86_64initramfs-3.10.0-957.el7.x86_64.imgvmlinuz-5.4.6-1.el7.elrepo.x86_64initramfs-5.4.6-1.el7.elrepo.x86_64.img#ls /lib/modules3.10.0-957.el7.x86_645.4.6-1.el7.elrepo.x86_64#reboot#uname -r5.4.6-1.el7.elrepo.x86_642.3.3.3 只下载相关的依赖包,而不安装#/data/目录如果不存在,会自动创建#yum -y install --downloadonly --downloaddir=/data/httpd httpd#ls /data/httpd/apr-1.6.3-9.el8.x86_64.rpmhttpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64.rpmapr-util-1.6.1-6.el8.x86_64.rpmhttpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch.rpmapr-util-bdb-1.6.1-6.el8.x86_64.rpmhttpd-tools-2.4.37-16.module_el8.1.0+256+ae790463.x86_64.rpmapr-util-openssl-1.6.1-6.el8.x86_64.rpmmailcap-2.1.48-3.el8.noarch.rpmcentos-logos-httpd-80.5-2.el8.noarch.rpm mod_http2-1.11.3-3.module_el8.1.0+213+acce2796.x86_64.rpm2.3.4 卸载程序包yum remove | erase package1 [package2] [...]2.3.5 升级和降级检查可用升级yum check-update升级和降级yum upgrade|update [package1] [package2] [...]upgrade-minimal#最小化升级yum downgrade package1 [package2] [...] (降级)范例[root@centos7 ~]# cat /etc/yum.repos.d/base.repo[base]name=aliyum basebaseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearchgpgcheck=1gpgkey=https://mirrors.aliyun.com/centos/$releasever/os/x86_64/RPM-GPG-KEY-CentOS-$releaseverenabled=1[update]name=aliyun updatebaseurl=https://mirrors.aliyun.com/centos/7/updates/x86_64/gpgcheck=0[root@centos7 ~]#yum --disablerepo=* --enablerep=updates list available[root@centos7 ~]#yum info sambaLoaded plugins: fastestmirrorRepository ‘updates‘ is missing name in configuration, using idLoading mirror speeds from cached hostfile* base:* elrepo: elrepo.0m3n.netAvailable PackagesName: sambaArch: x86_64Version: 4.9.1Release: 10.el7_7Size: 685 kRepo: updatesSummary: Server and Client software to interoperate with Windows machinesURL : http://www.samba.org/License: GPLv3+ and LGPLv3+Description : Samba is the standard Windows interoperability suite of programsfor Linux and : Unix.[root@centos7 ~]#yum info samba --showduplicatesLoaded plugins: fastestmirrorRepository ‘updates‘ is missing name in configuration, using idLoading mirror speeds from cached hostfile* base:* elrepo: elrepo.0m3n.netLoaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.cn99.comAvailable PackagesName: sambaArch: x86_64Version : 4.10.16Release : 5.el7Size: 717 kRepo: base/7/x86_64Summary : Server and Client software to interoperate with Windows: machinesURL : http://www.samba.org/License : GPLv3+ and LGPLv3+Description : Samba is the standard Windows interoperability suite of: programs for Linux and Unix.Name: sambaArch: x86_64Version : 4.10.16Release : 7.el7_9Size: 718 kRepo: updates/7/x86_64Summary : Server and Client software to interoperate with Windows: machinesURL : http://www.samba.org/License : GPLv3+ and LGPLv3+Description : Samba is the standard Windows interoperability suite of: programs for Linux and Unix.Name: sambaArch: x86_64Version : 4.10.16Release : 9.el7_9Size: 718 kRepo: updates/7/x86_64Summary : Server and Client software to interoperate with Windows: machinesURL : http://www.samba.org/License : GPLv3+ and LGPLv3+Description : Samba is the standard Windows interoperability suite of: programs for Linux and Unix.Name: sambaArch: x86_64Version : 4.10.16Release : 13.el7_9Size: 719 kRepo: updates/7/x86_64Summary : Server and Client software to interoperate with Windows: machinesURL : http://www.samba.org/License : GPLv3+ and LGPLv3+Description : Samba is the standard Windows interoperability suite of: programs for Linux and Unix.[root@centos7 ~]#yum install samba --disablerepo=updates[root@centos7 ~]#yum update samba[root@centos7 ~]#yum update2.3.6 yum查询包 info provides search

查看程序包information

yum info [...]

查看指定的特性(可以是某文件)是由哪个程序包所提供

yum provides | whatprovides feature1 [feature2] [...]

注意:文件要写全路径,而不只是文件名,否则可能无法查询到

范例#注意要写文件全路径才能查询到[root@centos8 ~]#yum provides vsftpd.conf# yum provides /etc/vsftpd/vsftpd.confLoaded plugins: fastestmirrorvsftpd-3.0.2-28.el7.x86_64 : Very Secure Ftp DaemonRepo: baseMatched from:Filename: /etc/vsftpd/vsftpd.conf#使用通配符#yum provides */vsftpd.conf#yum provides */updatedb*

以指定的关键字搜素程序名及summary信息

yum search string1 [string2] [...]

查看指定包所依赖的capabilities

yum deplist package1 [package2] [...]范例#yum info bashLoaded plugins: fastestmirrorInstalled PackagesName: bashArch: x86_64Version : 4.2.46Release : 34.el7Size: 3.5 MRepo: installedFrom repo: anacondaSummary : The GNU Bourne Again shellURL : http://www.gnu.org/software/bashLicense : GPLv3+Description : The GNU Bourne Again shell (Bash) is a shell or command: language interpreter that is compatible with the Bourne: shell (sh). Bash incorporates useful features from the Korn: shell (ksh) and the C shell (csh). Most sh scripts can be: run by bash without modification.#yum list bash*Loaded plugins: fastestmirrorInstalled Packagesbash.x86_644.2.46-34.el7@anacondabash-completion.noarch 1:2.1-8.el7 @baseAvailable Packagesbash-argsparse.noarch1.7-1.el7epel bash-completion-extras.noarch1:2.1-11.el7epel bash-doc.x86_644.2.46-34.el7base bashmount.noarch3.2.0-3.el7 epel#yum provides /bin/lsLoaded plugins: fastestmirrorcoreutils-8.22-24.el7.x86_64 : A set of basic GNU tools commonly used in : shell scriptsRepo: baseMatched from:Filename: /bin/lscoreutils-8.22-24.el7_9.2.x86_64 : A set of basic GNU tools commonly used : in shell scriptsRepo: updatesMatched from:Filename: /bin/lscoreutils-8.22-24.el7.x86_64 : A set of basic GNU tools commonly used in : shell scriptsRepo: @anacondaMatched from:Filename: /bin/ls#rpm -ivh /misc/cd/AppStream/Packages/httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64.rpmerror: Failed dependencies:/etc/mime.types is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64httpd-filesystem is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64httpd-filesystem = 2.4.37-16.module_el8.1.0+256+ae790463 is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64httpd-tools = 2.4.37-16.module_el8.1.0+256+ae790463 is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64libapr-1.so.0()(64bit) is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64libaprutil-1.so.0()(64bit) is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64mod_http2 is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64system-logos-httpd is needed by httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64#yum provides /etc/mime.typesLast metadata expiration check: 0:43:08 ago on Wed 08 Apr 2020 03:15:02 PM CST.mailcap-2.1.48-3.el8.noarch : Helper application and MIME type associations forfile typesRepo: BaseOSMatched from:Filename: /etc/mime.types#yum deplist httpdLast metadata expiration check: 0:41:15 ago on Wed 08 Apr 2020 03:15:02 PM CST.package: httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64dependency: /bin/sh provider: bash-4.4.19-10.el8.x86_64dependency: /etc/mime.types provider: mailcap-2.1.48-3.el8.noarchdependency: httpd-filesystem provider: httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarchdependency: httpd-filesystem = 2.4.37-16.module_el8.1.0+256+ae790463 provider: httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarchdependency: httpd-tools = 2.4.37-16.module_el8.1.0+256+ae790463 provider: httpd-tools-2.4.37-16.module_el8.1.0+256+ae790463.x86_64dependency: libapr-1.so.0()(64bit) provider: apr-1.6.3-9.el8.x86_64dependency: libaprutil-1.so.0()(64bit) provider: apr-util-1.6.1-6.el8.x86_64dependency: libbrotlienc.so.1()(64bit) provider: brotli-1.0.6-1.el8.x86_64dependency: libc.so.6(GLIBC_2.14)(64bit) provider: glibc-2.28-72.el8.x86_64dependency: libcrypt.so.1()(64bit) provider: libxcrypt-4.1.1-4.el8.x86_64dependency: libcrypt.so.1(XCRYPT_2.0)(64bit) provider: libxcrypt-4.1.1-4.el8.x86_64dependency: libdl.so.2()(64bit) provider: glibc-2.28-72.el8.x86_64dependency: libexpat.so.1()(64bit) provider: expat-2.2.5-3.el8.x86_64dependency: liblua-5.3.so()(64bit) provider: lua-libs-5.3.4-11.el8.x86_64dependency: libm.so.6()(64bit) provider: glibc-2.28-72.el8.x86_64dependency: libpcre.so.1()(64bit) provider: pcre-8.42-4.el8.x86_64dependency: libpthread.so.0()(64bit) provider: glibc-2.28-72.el8.x86_64dependency: libpthread.so.0(GLIBC_2.2.5)(64bit) provider: glibc-2.28-72.el8.x86_64dependency: libselinux.so.1()(64bit) provider: libselinux-2.9-2.1.el8.x86_64dependency: libsystemd.so.0()(64bit) provider: systemd-libs-239-18.el8.x86_64dependency: libsystemd.so.0(LIBSYSTEMD_209)(64bit) provider: systemd-libs-239-18.el8.x86_64dependency: libz.so.1()(64bit) provider: zlib-1.2.11-10.el8.x86_64dependency: mod_http2 provider: mod_http2-1.11.3-3.module_el8.1.0+213+acce2796.x86_64dependency: rtld(GNU_HASH) provider: glibc-2.28-72.el8.i686 provider: glibc-2.28-72.el8.x86_64dependency: system-logos-httpd provider: centos-logos-httpd-80.5-2.el8.noarchdependency: systemd-units provider: systemd-239-18.el8.i686 范例: centos7 查看未安装的文件列表#rpm -q memcachedpackage memcached is not installed#yum -y install yum-utils#repoquery -ql memcached/etc/sysconfig/memcached/usr/bin/memcached/usr/bin/memcached-tool/usr/lib/systemd/system/memcached.service/usr/share/doc/memcached-1.4.15......范例: centos8 查看未安装的文件列表#rpm -q memcachedpackage memcached is not installed#dnf repoquery -l memcached/etc/sysconfig/memcached/usr/bin/memcached......

•••展开全文