[CentOS 7系列]YUM安装(上)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[CentOS 7系列]YUM安装(上)相关的知识,希望对你有一定的参考价值。

1、YUM工具

命  令作  用
yum list列出可用安装包
yum search packet-name搜索包
yum install [-y] packet-name 安装包
yum grouplist查看可能批量安装的列表
yum groupinstall [-y] group-name批量安装包
yum remove [-y] packet-name卸载包
yum update [-y] packet-name升级包
yum provides "/*/file"查看特定文件属于哪个软件包
ls /etc/yum.repos.dyum源的配置文件夹

测试示例:

[[email protected] ~]# yum info | more
已加载插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
已安装的软件包
名称    :GeoIP
架构    :x86_64
版本    :1.5.0
发布    :11.el7
大小    :2.8 M
源    :installed
来自源:anaconda
简介    : Library for country/city/organization to IP address or hostname
         : mapping
网址    :http://www.maxmind.com/app/c
协议    : LGPLv2+ and GPLv2+ and CC-BY-SA
描述    : GeoIP is a C library that enables the user to find the country that
         : any IP address or hostname originates from. It uses a file based
         : database that is accurate as of June 2007 and can optionally be
         : updated on a weekly basis by installing the GeoIP-update package.
         : This database simply contains IP blocks as keys, and countries as
         : values. This database should be more complete and accurate than using
         : reverse DNS lookups.
         :
         : This package includes GeoLite data created by MaxMind, available from
         :http://www.maxmind.com/
......
[[email protected] ~]# yum install -y vim-enhanced
已加载插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                                                                                             | 3.6 kB  00:00:00
extras                                                                                                                                           | 3.4 kB  00:00:00
updates                                                                                                                                          | 3.4 kB  00:00:00
(1/2): extras/7/x86_64/primary_db                                                                                                                | 168 kB  00:00:00
(2/2): updates/7/x86_64/primary_db                                                                                                               | 6.4 MB  00:00:01
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 vim-enhanced.x86_64.2.7.4.160-1.el7_3.1 将被 安装
--> 正在处理依赖关系 vim-common = 2:7.4.160-1.el7_3.1,它被软件包 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 需要
......
--> 解决依赖关系完成
......

完毕!
[[email protected] ~]# ls /etc/yum.repos.d
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo


2、YUM本地仓库

1)挂载镜像到/mnt目录

[[email protected] ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载

2)备份yum配置文件

[[email protected] ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak

3)删除yum配置文件

[[email protected] ~]# rm -f /etc/yum.repos.d/*

4)编辑本地源

[[email protected] ~]# cat /etc/yum.repos.d/dvd.repo
[dvd]
name=install dvd
baseurl=file:///mnt
enable=1
gpcheck=0

5)清理软件源

[[email protected] ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: dvd
Cleaning up everything
Cleaning up list of fastest mirrors

6)查看可用安装包

[[email protected] ~]# yum list
......
389-ds-base-devel.x86_64                1.3.3.1-13.el7                 dvd
GConf2-devel.i686                       3.2.6-8.el7                    dvd
GConf2-devel.x86_64                     3.2.6-8.el7                    dvd
GeoIP-devel.i686                        1.5.0-9.el7                    dvd
GeoIP-devel.x86_64                      1.5.0-9.el7                    dvd
ImageMagick-c++-devel.i686              6.7.8.9-10.el7                 dvd
ImageMagick-c++-devel.x86_64            6.7.8.9-10.el7                 dvd
ImageMagick-devel.i686                  6.7.8.9-10.el7                 dvd
ImageMagick-devel.x86_64                6.7.8.9-10.el7                 dvd
LibRaw-devel.i686                       0.14.8-5.el7.20120830git98d925 dvd
LibRaw-devel.x86_64                     0.14.8-5.el7.20120830git98d925 dvd
ModemManager-devel.i686                 1.1.0-6.git20130913.el7        dvd
ModemManager-devel.x86_64               1.1.0-6.git20130913.el7        dvd
ModemManager-glib-devel.i686            1.1.0-6.git20130913.el7        dvd
ModemManager-glib-devel.x86_64          1.1.0-6.git20130913.el7        dvd
......


本文出自 “乱码时代” 博客,请务必保留此出处http://juispan.blog.51cto.com/943137/1942203

以上是关于[CentOS 7系列]YUM安装(上)的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 7.2 - yum系列 - 查看已安装的功能包或应用

[CentOS 7系列]源码包安装

[CentOS 7系列]RPM安装

CentOS yum 命令出现 [Errno 14] curl#6 - "Couldn't resolve host ..." 的解决方法(代码片段

python入门系列之一:Centos6下python2.7的安装

YUM安装Centos_linux Centos 6/7上安装GNOME桌面环境