Yum介绍与常见用法

本文主要介绍Yum的相关知识与Yum命令的常见用法。

1. Yum概述

对于Yum(yellowdog update modified),引用官网的概述,如下:

Yum is an automatic updater and package installer/remover for rpm systems. It automatically computes dependencies and figures out what things should occur to install packages. It makes it easier to maintain groups of machines without having to manually update each one using rpm. Yum has a plugin interface for adding simple features. Yum can also be used from other python programs via its module inteface.

2. 设置Yum源

关于Yum源,官网解释如下:

A package repository used by yum is simply a directory with one or more RPMs plus some "meta information" used by yum to be able to easily access information (dependencies, file lists, etc.) for the RPMs. Yum can then to access this directory over ftp/http or a file URI (including over NFS).

2.1 添加Yum源

2.1.1 添加centos 7的阿里源

1. 进入yum源的存储路径中:

cd /etc/yum.repos.d/

2. 使用wget命令下载centos 7的阿里源,如下:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3. 运行下面的命令,清除并重新生成yum缓存:

yum clean all
yum makecache

2.1.2 添加EPEL源

EPEL(Extra Packages for Enterprise Linux)是由Fedora社区打造的、为RHEL及其衍生发行版(如CentOS等)提供高质量软件包的项目。安装了EPEL源之后,就像在Fedora上一样,通过“yum install软件包名”,即可安装很多之前需要编译安装的软件、常用的软件以及一些比较流行的软件,比如现在流行的nginx、redis等。安装了EPEL源之后,都可以使用EPEL很方便的安装更新。

可以通过以下几种方法安装EPEL源。

2.1.2.1 方法1

在安装了centos 7的阿里源(或其他可用源)之后,我们可以直接通过下面的命令安装EPEL的yum源:

yum install epel-release

执行完上述操作后,能够在yum源路径/etc/yum.repos.d下看见epel的仓库文件,如下:


然后重新生成yum缓存,即可使用epel源了。

3. 常见用法

1. 搜索软件包:

yum search packagename

2. 安装软件包:

yum install packagename/groupname

3. 卸载软件包:

yum erase packagename/groupname

4. -y 选项:在交互过程中,对于所有的问题回答“yes”





猜你喜欢

转载自blog.csdn.net/liitdar/article/details/80266569