标签:
用于添加/删除/更新RPM包,自动解决包的依赖问题以及系统更新升级。
(1)用法:
用法: yum [参数] [软件名]
(2)功能:
功能: yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令。
简介: yum命令是在Fedora和RedHat以及SUSE中基于rpm的软件包管理器,它可以使系统管理人员交互和自动化地更细与管理RPM软件包,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。
(3)选项参数:
info,check-update,search,clean
install,remove,update,list
groupinstall,groupremove,groupupdate,grouplist
(4)实例:
1)[root@localhost sunjimeng]# yum check-update | more -15 检查可以更新的软件包
[root@localhost sunjimeng]# yum check-update | more -15 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn ModemManager.x86_64 1.1.0-8.git20130913.el7 base ModemManager-glib.x86_64 1.1.0-8.git20130913.el7 base NetworkManager.x86_64 1:1.0.6-29.el7_2 updates NetworkManager-adsl.x86_64 1:1.0.6-29.el7_2 updates NetworkManager-glib.x86_64 1:1.0.6-29.el7_2 updates NetworkManager-libnm.x86_64 1:1.0.6-29.el7_2 updates NetworkManager-libreswan.x86_64 1.0.6-3.el7 base NetworkManager-team.x86_64 1:1.0.6-29.el7_2 updates NetworkManager-tui.x86_64 1:1.0.6-29.el7_2 updates --More--
2)[root@localhost sunjimeng]# yum update 检查并更新所有软件包,这个命令被用来升级系统
[root@localhost sunjimeng]# yum update 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 ModemManager.x86_64.0.1.1.0-6.git20130913.el7 将被 升级 ---> 软件包 ModemManager.x86_64.0.1.1.0-8.git20130913.el7 将被 更新 ---> 软件包 ModemManager-glib.x86_64.0.1.1.0-6.git20130913.el7 将被 升级 ---> 软件包 ModemManager-glib.x86_64.0.1.1.0-8.git20130913.el7 将被 更新 ...... 事务概要 ================================================================================================================================= 安装 10 软件包 (+48 依赖软件包) 升级 697 软件包 总计:766 M Is this ok [y/d/N]: n Exiting on user command 您的事务已保存,请执行: yum load-transaction /tmp/yum_save_tx.2016-06-21.01-02.n0EVjx.yumtx 重新执行该事务
3)[root@localhost sunjimeng]# yum install yum-fastestmirror 自动搜索最快镜像插件并安装
[root@localhost sunjimeng]# yum install yum-fastestmirror 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 yum-plugin-fastestmirror.noarch.0.1.1.31-29.el7 将被 升级 ---> 软件包 yum-plugin-fastestmirror.noarch.0.1.1.31-34.el7 将被 更新 --> 解决依赖关系完成 依赖关系解决 ================================================================================================================================= Package 架构 版本 源 大小 ================================================================================================================================= 正在更新: yum-plugin-fastestmirror noarch 1.1.31-34.el7 base 30 k 事务概要 ================================================================================================================================= 升级 1 软件包 总计:30 k Is this ok [y/d/N]: y Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在更新 : yum-plugin-fastestmirror-1.1.31-34.el7.noarch 1/2 清理 : yum-plugin-fastestmirror-1.1.31-29.el7.noarch 2/2 验证中 : yum-plugin-fastestmirror-1.1.31-34.el7.noarch 1/2 验证中 : yum-plugin-fastestmirror-1.1.31-29.el7.noarch 2/2 更新完毕: yum-plugin-fastestmirror.noarch 0:1.1.31-34.el7 完毕!
4)[root@localhost sunjimeng]# yum search mysql-server 根据名称搜索软件包
[root@localhost sunjimeng]# yum list | grep mysql-server [root@localhost sunjimeng]# yum search mysql-server 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn ====================================================== 匹配:mysql-server ======================================================= akonadi-mysql.x86_64 : Akonadi MySQL backend support [root@localhost sunjimeng]# yum list | grep mysql akonadi-mysql.x86_64 1.9.2-4.el7 base apr-util-mysql.x86_64 1.5.2-6.el7 base dovecot-mysql.x86_64 1:2.2.10-5.el7 base freeradius-mysql.x86_64 3.0.4-6.el7 base libdbi-dbd-mysql.x86_64 0.8.3-16.el7 base mysql-connector-java.noarch 1:5.1.25-3.el7 base mysql-connector-odbc.x86_64 5.2.5-6.el7 base pcp-pmda-mysql.x86_64 3.10.6-2.el7 base php-mysql.x86_64 5.4.16-36.1.el7_2.1 updates php-mysqlnd.x86_64 5.4.16-36.1.el7_2.1 updates qt-mysql.i686 1:4.8.5-12.el7_2 updates qt-mysql.x86_64 1:4.8.5-12.el7_2 updates redland-mysql.x86_64 1.0.16-6.el7 base rsyslog-mysql.x86_64 7.4.7-12.el7 base [root@localhost sunjimeng]# yum search mysql 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn ====================================================== N/S matched: mysql ======================================================= MySQL-python.x86_64 : An interface to MySQL akonadi-mysql.x86_64 : Akonadi MySQL backend support apr-util-mysql.x86_64 : APR utility library MySQL DBD driver dovecot-mysql.x86_64 : MySQL back end for dovecot freeradius-mysql.x86_64 : MySQL support for freeradius libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi mysql-connector-java.noarch : Official JDBC driver for MySQL mysql-connector-odbc.x86_64 : ODBC driver for MySQL pcp-pmda-mysql.x86_64 : Performance Co-Pilot (PCP) metrics for MySQL perl-DBD-MySQL.x86_64 : A MySQL interface for Perl php-mysql.x86_64 : A module for PHP applications that use MySQL databases php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases qt-mysql.i686 : MySQL driver for Qt‘s SQL classes qt-mysql.x86_64 : MySQL driver for Qt‘s SQL classes qt3-MySQL.i686 : MySQL drivers for Qt 3‘s SQL classes qt3-MySQL.x86_64 : MySQL drivers for Qt 3‘s SQL classes redland-mysql.x86_64 : MySQL storage support for Redland rsyslog-mysql.x86_64 : MySQL support for rsyslog mariadb.x86_64 : A community developed branch of MySQL mariadb-devel.i686 : Files for development of MariaDB/MySQL applications mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients 名称和简介匹配 only,使用“search all”试试。
4)[root@localhost sunjimeng]# yum install mysql 安装指定的软件
[root@localhost sunjimeng]# yum install mysql 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 软件包 1:mariadb-5.5.47-1.el7_2.x86_64 已安装并且是最新版本 无须任何处理 [root@localhost sunjimeng]# yum install mysql-devel 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 软件包 1:mariadb-devel-5.5.47-1.el7_2.x86_64 已安装并且是最新版本 无须任何处理 [root@localhost sunjimeng]# yum install mysql-server 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 没有可用软件包 mysql-server。 错误:无须任何处理 //安装mysql数据库需要三个软件:mysql,mysql-deverl,和mysql-server。
4)[root@localhost sunjimeng]# yum remove httpd 删除指定的软件包
[root@localhost sunjimeng]# yum remove httpd 已加载插件:fastestmirror, langpacks 正在解决依赖关系 --> 正在检查事务 ---> 软件包 httpd.x86_64.0.2.4.6-40.el7.centos.1 将被 删除 --> 解决依赖关系完成 依赖关系解决 ================================================================================================================================= Package 架构 版本 源 大小 ================================================================================================================================= 正在删除: httpd x86_64 2.4.6-40.el7.centos.1 @updates 9.4 M 事务概要 ================================================================================================================================= 移除 1 软件包 安装大小:9.4 M 是否继续?[y/N]:y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在删除 : httpd-2.4.6-40.el7.centos.1.x86_64 1/1 验证中 : httpd-2.4.6-40.el7.centos.1.x86_64 1/1 删除: httpd.x86_64 0:2.4.6-40.el7.centos.1 完毕!
5)[root@localhost sunjimeng]# yum -y install httpd 给指定命令-y参数默认所有的询问都答Y。
[root@localhost sunjimeng]# yum -y install httpd 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 httpd.x86_64.0.2.4.6-40.el7.centos.1 将被 安装 --> 解决依赖关系完成 依赖关系解决 ================================================================================================================================= Package 架构 版本 源 大小 ================================================================================================================================= 正在安装: httpd x86_64 2.4.6-40.el7.centos.1 updates 2.7 M 事务概要 ================================================================================================================================= 安装 1 软件包 总下载量:2.7 M 安装大小:9.4 M Downloading packages: httpd-2.4.6-40.el7.centos.1.x86_64.rpm | 2.7 MB 00:00:21 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : httpd-2.4.6-40.el7.centos.1.x86_64 1/1 验证中 : httpd-2.4.6-40.el7.centos.1.x86_64 1/1 已安装: httpd.x86_64 0:2.4.6-40.el7.centos.1 完毕!
6)[root@localhost sunjimeng]# yum deplist httpd 获得指定软件包的依赖关系
[root@localhost sunjimeng]# yum deplist httpd 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 软件包:httpd.x86_64 2.4.6-40.el7.centos.1 依赖:/bin/sh provider: bash.x86_64 4.2.46-19.el7 依赖:/etc/mime.types provider: mailcap.noarch 2.1.41-2.el7 依赖:/usr/sbin/groupadd provider: shadow-utils.x86_64 2:4.1.5.1-18.el7 依赖:/usr/sbin/useradd provider: shadow-utils.x86_64 2:4.1.5.1-18.el7 依赖:httpd-tools = 2.4.6-40.el7.centos.1 provider: httpd-tools.x86_64 2.4.6-40.el7.centos.1 依赖:libapr-1.so.0()(64bit) provider: apr.x86_64 1.4.8-3.el7 依赖:libaprutil-1.so.0()(64bit) provider: apr-util.x86_64 1.5.2-6.el7 依赖:libc.so.6(GLIBC_2.4)(64bit) provider: glibc.x86_64 2.17-106.el7_2.6 依赖:libcrypt.so.1()(64bit) provider: glibc.x86_64 2.17-106.el7_2.6 依赖:libdb-5.3.so()(64bit) provider: libdb.x86_64 5.3.21-19.el7 依赖:libdl.so.2()(64bit) provider: glibc.x86_64 2.17-106.el7_2.6 依赖:libexpat.so.1()(64bit) provider: expat.x86_64 2.1.0-8.el7 依赖:liblua-5.1.so()(64bit) provider: lua.x86_64 5.1.4-14.el7 依赖:libm.so.6()(64bit) provider: glibc.x86_64 2.17-106.el7_2.6 依赖:libpcre.so.1()(64bit) provider: pcre.x86_64 8.32-15.el7_2.1 依赖:libpthread.so.0()(64bit) provider: glibc.x86_64 2.17-106.el7_2.6 依赖:libpthread.so.0(GLIBC_2.2.5)(64bit) provider: glibc.x86_64 2.17-106.el7_2.6 依赖:libselinux.so.1()(64bit) provider: libselinux.x86_64 2.2.2-6.el7 依赖:libsystemd-daemon.so.0()(64bit) provider: systemd-libs.x86_64 219-19.el7_2.9 依赖:libsystemd-daemon.so.0(LIBSYSTEMD_DAEMON_31)(64bit) provider: systemd-libs.x86_64 219-19.el7_2.9 依赖:libz.so.1()(64bit) provider: zlib.x86_64 1.2.7-15.el7 依赖:rtld(GNU_HASH) provider: glibc.x86_64 2.17-106.el7_2.6 provider: glibc.i686 2.17-106.el7_2.6 依赖:system-logos >= 7.92.1-1 provider: centos-logos.noarch 70.0.6-3.el7.centos 依赖:systemd-units provider: systemd.x86_64 219-19.el7_2.9
7)[root@localhost sunjimeng]# yum info httpd 查看指定软件包的信息
[root@localhost sunjimeng]# yum info httpd 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 已安装的软件包 名称 :httpd 架构 :x86_64 版本 :2.4.6 发布 :40.el7.centos.1 大小 :9.4 M 源 :installed 来自源:updates 简介 : Apache HTTP Server 网址 :http://httpd.apache.org/ 协议 : ASL 2.0 描述 : The Apache HTTP Server is a powerful, efficient, and extensible : web server.
8)[root@localhost sunjimeng]# yum grouplist 查看系统中已经安装的和可用的软件组,对于可用的软件组,你可以选择安装
[root@localhost sunjimeng]# yum grouplist 已加载插件:fastestmirror, langpacks 没有安装组信息文件 Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn Available environment groups: 最小安装 基础设施服务器 计算节点 文件及打印服务器 基本网页服务器 虚拟化主机 带 GUI 的服务器 GNOME 桌面 KDE Plasma Workspaces 开发及生成工作站 可用组: 传统 UNIX 兼容性 兼容性程序库 图形管理工具 安全性工具 开发工具 控制台互联网工具 智能卡支持 科学记数法支持 系统管理 系统管理工具 完成
9)[root@localhost sunjimeng]# yum groupinstall GNOME 桌面 安装上一个命令中显示的可用的软件组中的一个软件组
[root@localhost sunjimeng]# yum groupinstall GNOME 桌面 //安装对应的删除和更新分别是groupremove,groupupdate 已加载插件:fastestmirror, langpacks 没有安装组信息文件 Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.yun-idc.com * updates: mirrors.cug.edu.cn 正在解决依赖关系 --> 正在检查事务 ---> 软件包 NetworkManager-libreswan-gnome.x86_64.0.1.0.6-3.el7 将被 安装 ...... 事务概要 ================================================================================================================================= 安装 7 软件包 (+ 24 依赖软件包) 升级 3 软件包 (+145 依赖软件包) 总计:204 M 总下载量:7.7 M Is this ok [y/d/N]: y Downloading packages: ...... 替代: PackageKit-device-rebind.x86_64 0:0.8.9-11.el7.centos adwaita-gtk3-theme.x86_64 0:3.8.4-3.el7 gnome-settings-daemon-updates.x86_64 0:3.8.6.1-12.el7 totem-mozplugin.x86_64 1:3.8.2-5.el7 完毕!
10) [root@localhost sunjimeng]# yum clean headers 清除命令
[root@localhost sunjimeng]# yum clean headers //清除头文件 已加载插件:fastestmirror, langpacks 正在清理软件源: base extras updates 0 header 文件已移除 [root@localhost sunjimeng]# yum clean packages //清除包文件 已加载插件:fastestmirror, langpacks 正在清理软件源: base extras updates 580 package 文件已移除 [root@localhost sunjimeng]# yum clean //必须加上参数 已加载插件:fastestmirror, langpacks 错误:清理命令需要参数:headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all [root@localhost sunjimeng]# yum clean all //清除所有 已加载插件:fastestmirror, langpacks 正在清理软件源: base extras updates Cleaning up everything Cleaning up list of fastest mirrors
(5)其他:
标签:
原文地址:http://www.cnblogs.com/MenAngel/p/5604180.html