CentOS下yum命令详解
Yum: 即Yellowdog Update Modifier,是一种基于rpm的包管理工具
yum命令使用示例
显示yum仓库
显示所有仓库
yum repolist all
显示可用的仓库
repolist enabled
显示可用的仓库
repolist disabled
显示应用程序包
显示所有的程序包
yum list
或
yum list all
[vathe@localhost ~]$yum list tre?
Installed Packages
tree.x86_64 1.6.0-10.el7 @base
还支持通配符格式的查询
显示可安装的程序包
yum list available
[vathe@localhost ~]$yum list available php
Available Packages
php.x86_64 5.4.16-42.el7 base
显示可更新或已安装的程序包
yum list updates
yum list installed
显示仓库中最近增加的程序包
yum list recent
安装程序包
#安装 tree 程序
yum install tree
升级程序包
yum update tree
卸载程序包
yum remove tree
或
yum erase tree
查看程序包信息
yum info tree
查看文件的来源
查看某一文件来自于那个程序包
[vathe@localhost ~]$yum provides /bin/mv
coreutils-8.22-18.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : base
Matched from:
Filename : /bin/mv
#表示/bin/mv文件来自于coreutils-8.22-18.el7.x86_64程序包
清理本地缓存
yum clean all
#清楚插件缓存
yum clean plugins
构建缓存
yum makecache
搜索
[vathe@localhost ~]$yum search php
============================================== N/S matched: php ===============================================
graphviz-php.x86_64 : PHP extension for graphviz
php.x86_64 : PHP scripting language for creating dynamic web sites
php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
...
查看指定包所依赖的capabilities
[vathe@localhost ~]$yum deplist php
package: php.x86_64 5.4.16-42.el7
dependency: httpd
provider: httpd.x86_64 2.4.6-45.el7.centos
...
查看yum事务历史
[root@localhost ~]# yum history
Repository 'base' is missing name in configuration, using id
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
2 | Vathe Su <vathe> | 2017-04-17 17:07 | Install | 1
1 | System <unset> | 2017-03-23 22:19 | Install | 1405
history list
包组相关的命令
yum groupinstall # 安装包组
yum groupupdate #更新包组
yum grouplist #显示包组
yum groupremove #移除包组
yum groupinfo #查看包组信息
这些命令和上面的命令用法类似,只是针对于包组而言