本文根据 Devhints / YUM 翻译。代码示例及版本范围沿用原文。原文标注更新日期:2024-02-07。
命令
帮助与列表
yum help # Display yum commands and options
yum list available # List all available packages
yum list installed # List all installed packages
yum list kernel # List installed and available kernel packages
yum info vsftpd # List info about vsftpd package
搜索与依赖关系
yum deplist nfs-utils # List dependencies for nfs-utils
yum provides "*bin/top" # Show package containing top command
yum search samba # Find packages with samba in name or description
更新与安全性
yum updateinfo security # Get info on available security updates
yum update --security # Apply security-related package updates
管理仓库
yum repolist # Display enabled software repositories
yum repoinfo rhel-7-server-rpms # See info on specific repo
yum repo-pkgs my-rpms list # List packages from a specific repo
安装与升级
yum install vsftpd # Install the vsftpd package
yum update # Update all packages
yum downgrade abc # Downgrade the abc package to an earlier version
yum autoremove httpd # Remove httpd and unneeded packages
软件包组
yum groupinstall "Web server" # Install Web Server packages
故障排除
yum history list # List all yum transactions
yum clean packages # Delete packages saved in cache
常用选项
-y # Assume yes if prompted
--disablerepo=epel # Disable a specific repo for a command
--downloadonly # Download package to cache but don't install