引言
Yum(Yellow dog Updater, Modified)是Red Hat Enterprise Linux(RHEL)中常用的软件包管理器,它基于RPM包管理,能够自动下载RPM包并安装,同时自动处理依赖性关系。本文将详细介绍Yum的使用方法,帮助您轻松掌握RHEL软件安装技巧。
Yum的安装
在标准的RHEL上,默认没有安装Yum。以下是在RHEL AS release 4 (Nahant)上安装Yum的步骤:
- 下载Yum安装包:yumforAS4.tar.gz 或 yumforAS4.tar.gz
- 解压缩并安装:
[root@DEV-191 aio]# tar zxvf yumforAS4.tar.gz yumforAS4/ yumforAS4/CentOS-Base.repo yumforAS4/python-elementtree-1.2.6-7.el4.rf.i386.rpm ... [root@DEV-191 aio]# yum install yumforAS4/python-elementtree-1.2.6-7.el4.rf.i386.rpm ...
Yum常用命令
以下是一些常用的Yum命令:
- 清除缓存目录:
yum clean all
- 更新缓存:
yum makecache
- 查找软件包:
yum search telnet
- 安装软件包:
yum install telnet
- 删除软件包:
yum remove telnet
- 安装更新软件:
yum update
或yum update telnet
Yum源配置
Yum源是指Yum下载软件包的服务器地址。以下是在RHEL中配置Yum源的步骤:
- 进入YUM源目录:
cd /etc/yum.repos.d
- 备份自带YUM源配置文件:
mv rhel-source.repo rhel-source.repo.bak
- 下载阿里云的CentOS 6 YUM源配置文件:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
- 编辑CentOS-Base.repo文件:
vim CentOS-Base.repo
- 将文件里的所有
releasever
替换为6.7,保存并退出。
Yum与Kickstart
Kickstart是一种自动化安装RHEL的工具。通过创建一个Kickstart文件,可以自动完成安装过程中的所有操作。以下是在Kickstart文件中配置Yum源的示例:
# / Kickstart file for automated installation
# System timezone
timezone --isUtc
# Network information
network --bootproto=dhcp
# System language
lang en_US.UTF-8
# Root password
rootpw --iscrypted $1$...
# Reboot after installation
reboot
# Firewall configuration
firewall --disabled
# Install packages
@base
@development
@isdn
@kernel
@networking
@xwindow
# Yum repository configuration
repo --name="CentOS" --baseurl=http://mirrors.aliyun.com/repo/Centos-6.repo --enable
# Install the bootloader
bootloader --location=mbr
总结
Yum是RHEL中强大的软件包管理器,通过本文的介绍,相信您已经掌握了Yum的使用技巧。在实际应用中,可以根据需要配置Yum源、使用Yum命令安装和更新软件包,以及利用Kickstart实现自动化安装。