yum命令来自英文词组“YellowdogUpdater Modified”的缩写,其功能是用于在Linux系统中基于RPM技术进行软件包的管理工作。yum技术通用于RHEL、CentOS、Fedora、OpenSUSE等主流系统,可以让系统管理人员交互式地自动化更新和管理软件包,实现从指定服务器自动下载、更新、删除软件包的工作。
yum软件仓库及命令能够自动处理软件依赖关系,一次性安装所需全部软件,无须烦琐的操作。
语法格式:yum [参数] [动作] 软件包
常用参数:
-c | 设置配置文件路径 |
-C | 缓存中运行,不下载或更新任何头文件 |
-d | 设置调试等级(0-10) |
-e | 设置错误等级(0-10) |
-h | 显示帮助信息 |
-q | 静默执行模式 |
-R | 设置最大等待时间 |
-t | 检查外部错误 |
-v | 显示执行过程详细信息 |
-y | 所有询问均回答自动yes |
常用动作:
install | 安装软件包 |
update | 更新软件包 |
check-update | 检查是否有可用的更新软件包 |
remove | 删除软件包 |
list | 显示软件包的信息 |
search | 搜索指定软件包 |
info | 显示指定软件包的描述和概要信息 |
clean | 清理过期的缓存 |
shell | 设置使用的shell提示符 |
resolvedep | 显示软件包的依赖关系 |
localinstall | 安装本地软件包 |
localupdate | 更新本地软件包 |
deplist | 显示软件包的依赖关系 |
参考示例
清理原有的软件仓库信息缓存:
[root@linuxcool ~]# 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@linuxcool ~]# 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 83 MB/s | 5.3 MB 00:00 BaseOS 28 MB/s | 2.2 MB 00:00 Last metadata expiration check: 0:00:01 ago on Mon 09 May 2023 11:43:41 PM CST. Metadata cache created.
安装指定的服务及相关软件包:
[root@linuxcool ~]# yum install httpd ………………省略输出信息………………
更新指定的服务及相关软件包:
[root@linuxcool ~]# yum update httpd ………………省略输出信息………………
卸载指定的服务及相关软件包:
[root@linuxcool ~]# yum remove httpd ………………省略输出信息………………
显示可安装的软件包组列表:
[root@linuxcool ~]# yum grouplist Updating Subscription Management repositories. Unable to read consumer identity Last metadata expiration check: 0:03:02 ago on Mon 09 May 2023 11:43:41 PM CST. Available Environment Groups: Server Minimal Install Workstation Virtualization Host Custom Operating System Installed Environment Groups: Server with GUI Installed Groups: Container Management Headless Management Available Groups: .NET Core Development ………………省略部分输出信息………………
显示指定服务的软件信息:
[root@linuxcool ~]# yum info httpd Updating Subscription Management repositories. Unable to read consumer identity Last metadata expiration check: 0:07:21 ago on Mon 09 May 2023 11:43:41 PM CST. Installed Packages Name : httpd Version : 2.4.37 Release : 10.module+el8+2764+7127e69e Arch : x86_64 Size : 4.3 M Source : httpd-2.4.37-10.module+el8+2764+7127e69e.src.rpm Repo : @System From repo : AppStream Summary : Apache HTTP Server URL : https://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and extensible : web server.