rhel8的yum仓库配置及yum命令使用(RHEL8配置yum仓库、常用的yum命令记录)

  • 在RHEL8中,软件源分成了两部分,一个是BaseOS,另一个是AppStream

  • BaseOS 存储库 - BaseOS 存储库以传统 RPM 包的形式提供底层核心 OS 内容。

  • AppStream 存储库 - Application Stream 存储库提供用户可能希望在给定用户空间中运行的所有应用程序。

  • yum 软件仓库配置如下:

#编辑本地软件仓库源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim rhel8.repo
[Tom_yum]          #唯一标识符,不能重复
name=Tom_yum       #仓库名称,可任意取个名称
baseurl=file:///media/cdrom/BaseOS    #提供的方式,file:// 是本地仓库,http:// 是网络仓库
enabled=1        #是否可用,1表示启用,0表示不启用
gpgcheck=0       #是否校验,1表示要校验,0表示不检验
[AppStream]   #在RHEL8中还要配置AppStream仓库
name=AppStream    
baseurl=file:///media/cdrom/AppStream  
enabled=1      
gpgcheck=0      
[root@localhost yum.repos.d]# ls
redhat.bak  redhat.repo  rhel8.repo

  • 接下来清理缓存、建立元数据,操作如下:
[root@michael ~]# 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@michael ~]# 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.
AppStream                                         41 MB/s | 5.3 MB     00:00    
Tom_yum                                           21 MB/s | 2.2 MB     00:00    
Last metadata expiration check: 0:00:01 ago on Sun 31 Oct 2021 01:03:07 PM CST.
#上次元数据过期检查:0:00:01 前,执行于 2021年10月31日 星期日 13时3分7秒。
Metadata cache created.		#元数据缓存已建立

  • 查看在用的yum源
[root@michael ~]# 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.
Last metadata expiration check: 0:04:57 ago on Sun 31 Oct 2021 01:03:07 PM CST.
repo id                    repo name                   status
AppStream                  AppStream                   enabled: 4,672
Tom_yum                    Tom_yum                     enabled: 1,658

  • 在RHEL8中,yum 命令与 dnf 命令是一样的,dnf 命令更好的解决了软件依赖问题。常用命令如下:
dnf repolist	#查看系统中可用的 DNF 软件库
dnf repolist all	#查看系统中可用和不可用的 DNF 软件库
dnf list		#列出所有RPM包
dnf list installed	#列出所有安装了的RPM包
dnf list available	#列出所有可供安装的RPM包
dnf search nano		#搜索软件仓库中的RPM包
dnf provides /bin/bash	#查找一些软件的提供者
dnf info nginx		#查看软件包详情
dnf install nginx	#安装软件包
dnf remove nginx	#删除软件包
dnf autoremove		#删除无用孤立的软件包
dnf clean all		#删除缓存的无用软件包
dnf help clean		#获取某条命令的使用帮助
dnf history			#查看命令执行历史
dnf grouplist		#查看所有的软件包组
dnf groupinstall "安全性工具"	#安装一个软件包组
dnf -enablerepo=epel install nginx	#从特定的软件包库安装特定的软件
dnf reinstall nano	#重新安装软件包
posted @ 2021-11-07 16:15  远方那一抹云  阅读(1428)  评论(0编辑  收藏  举报