yum 是一个强大的命令行工具,可用于更加灵活地管理(安装、更新、删除和查询)软件包。
Table 1. 常用 yum 命令
命令
描述
yum list [NAME-PATTERN]
按名称列出已安装和可用的软件包
yum grouplist
列出已安装和可用的组
yum search KEYWORD
按关键字搜索软件包
yum info PACKAGENAME
显示软件包的详细信息
yum install PACKAGENAME
安装软件包
yum groupinstall "GROUPNAME"
安装软件包组
yum update
更新所有软件包
yum remove PACKAGENAME
删除软件包
yum history
显示事务历史记录
使用 yum 查找软件包
查看 repositories
# yum repolist
yum list 显示已安装的和可用的软件包
# yum list 'http*'*
查看已安装的包
# yum list installed
查看 package groups
# yum grouplist
查着包
# yum search all 'web server'
查着包
# yum provides /var/www/html
查看包详细情况
# yum info httpd
使用 yum 安装和删除软件包
安装包
# yum install httpd
更新包
# yum update
移除包
# yum remove httpd
group 安装
# yum group install "Infiniband Support"
查看事务历史记录
查看安装的历史
# yum history
查看 yum 日志 /var/log/yum.log
Dec 05 16:09:59 Installed: apr-1.4.8-3.el7_4.1.x86_64
Dec 05 16:09:59 Installed: apr-util-1.5.2-6.el7.x86_64
Dec 05 16:10:00 Installed: httpd-tools-2.4.6-67.el7_4.6.x86_64
Dec 05 16:10:00 Installed: mailcap-2.1.41-2.el7.noarch
...
yum history undo
//安装
# yum search gnuplot
# yum info gnuplot
# yum install -y gnuplot
//查看已安装的包
# yum list gnuplot*
Installed Packages
gnuplot.x86_64 4.6.2-3.el7 @rhel-7-server-rpms
gnuplot-common.x86_64 4.6.2-3.el7 @rhel-7-server-rpms
//移除
# yum remove gnuplot
# yum remove gnuplot-common
//group 安装
# yum group list
# yum group info "Compatibility Libraries"
# yum group install "Compatibility Libraries"
//查看历史
# yum history
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
5 | root | 2017-12-05 16:40 | Install | 12
4 | root | 2017-12-05 16:29 | Install | 2
3 | root | 2017-12-05 16:20 | I, O, U | 157 EE
2 | root | 2017-12-05 16:09 | Install | 5
1 | System | 2017-12-05 11:29 | Install | 1298
# yum history undo 5
# yum history undo 4