日期:2014-05-16  浏览次数:20635 次

15个Linux Yum命令实例--安装/卸载/更新

本文译自http://www.thegeekstuff.com/2011/08/yum-command-examples/

?

第一次翻译外文,如有不正确之处请指出. ?至于版权, 应该是属于原作者吧. 闹球不清.

?

? ? 在linux环境中, 安装, 卸载更新包是一个极为常见的操作.大部分的linux环境都提供了包的管理工具, 例如:apt-get, dpkg, rpm, yum等等.

?

? ? 一些Linux环境中,yum是默认的包管理工具.Yum是Yellowdog Updater Modified的简称.


?该文章阐释了经常被使用到yum命令的15个场景.

?

1> 使用yum install 安装包.

?

? ? ?要安装一个包,使用 'yum install 包名'. 该命令将会自动的安装该包的依赖.

?

# yum install postgresql.x86_64
Resolving Dependencies
Install       2 Package(s)
Is this ok [y/N]: y

Package(s) data still to download: 3.0 M
(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm          | 2.8 MB     00:11
(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm    | 203 kB     00:00
------------------------------
Total                                        241 kB/s | 3.0 MB     00:12     

Running Transaction
  Installing : postgresql-libs-9.0.4-5.fc15.x86_64             1/2
  Installing : postgresql-9.0.4-5.fc15.x86_64                   2/2 

Complete!

?

默认的'yum install'命令, 将会在安装这些包之前 提示你"接受"或"放弃", 如果想要使用yum自动安装包,而不对你进行提示. 使用 -y 选项. 如下所示:

?

# yum -y install postgresql.x86_64

?

2> 使用yum remove 卸载包.

?

? 如下所示:使用'yum remove 包名' 命令卸载包.

?

# yum remove  postgresql.x86_64
Resolving Dependencies
---> Package postgresql.x86_64 0:9.0.4-5.fc15 will be erased

Is this ok [y/N]: y

Running Transaction
  Erasing    : postgresql-9.0.4-5.fc15.x86_64       1/1 

Removed:
  postgresql.x86_64 0:9.0.4-5.fc15

Complete!

?

3> 使用 'yum update'命令升级