yum对于使用linux系统服务器的朋友估计并不陌生了,今天我们给各位介绍linux中yum软件包管理例子,希望下文可以帮助到各位.
Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora、RedHat、CentOS中的Shell前端软件包管理器,基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,下面总结下yum的常用参数.
yum的命令形式一般是如下:yum [options] [command] [package ...]
其中的[options]是可选的,选项包括-h(帮助),-y(当安装过程提示选择全部为"yes"),-q(不显示安装的过程)等等,[command]为所要进行的操作,[package ...]是操作的对象.
概括了部分常用的命令包括:
自动搜索最快镜像插件:yum install yum-fastestmirror
安装yum图形窗口插件:yum install yumex
查看可能批量安装的列表:yum grouplist
1、yum安装软件包
#yum install curl 或 #yum -y install curl 或 不加y参数时是交互式的安装,需要按提示确认后才能安装,而加-y是静默模式,直接进行安装.
2、yum移除软件包
完全移除软件包及所有依赖包.
#yum remove curl 或 #yum -y remove curl
3、yum更新软件包
# yum update mysql
4、列出软件包
使用list函数,可搜索带名称的特定软件包,比如说,想搜索一个名为openssh的软件包,使用该命令.
- # yum list openssh
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * base: mirror.neu.edu.cn
- * epel: mirror.neu.edu.cn
- * extras: mirror.neu.edu.cn
- * rpmforge: mirror.nl.leaseweb.net
- * updates: mirror.nus.edu.sg
- Installed Packages
- openssh.i386 4.3p2-72.el5_6.3 installed
- Available Packages 4.3p2-82.el5 base
想让你的搜索更精确,明确软件包名称的版本,如果你知道的话,比如说,想搜索软件包的特定版本openssh-4.3p2,使用该命令.
# yum list openssh-4.3p2
5、Yum搜索软件包
要是你不记得软件包的确切名称,那么可以使用search或search all,搜索与指定软件包的名称相匹配的所有可用软件包,比如说,想搜索与vsftpd这个单词匹配的所有软件包.
- [root@api test]# yum search vsftpd
- Loaded plugins: fastestmirror, security
- Determining fastest mirrors
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- base | 3.7 kB 00:00
- extras | 3.4 kB 00:00
- updates | 3.4 kB 00:00
- updates/primary_db | 2.1 MB 00:02
- =============================== N/S Matched: vsftpd ===================================
- vsftpd.x86_64 : Very Secure Ftp Daemon
- Name and summary matches only, use "search all" for everything.
- [root@api test]# yum search all vsftpd
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com --Vevb.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- ==============================================Matched: vsftpd ==========================
- vsftpd.x86_64 : Very Secure Ftp Daemon
6、Yum获取软件包信息
假设你想在安装软件包之前先知道它的信息,想获得某软件包的信息,只要执行下面这个命令.
- [root@api test]# yum info vsftpd
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- Installed Packages
- Name : vsftpd
- Arch : x86_64
- Version : 2.2.2
- Release : 11.el6
- Size : 331 k
- Repo : installed
- From repo : anaconda-CentOS-201207061011.x86_64
- Summary : Very Secure Ftp Daemon
- URL : http://vsftpd.beasts.org/
- License : GPLv2 with exceptions
- Description : vsftpd is a Very Secure FTP daemon. It was written completely from
- : scratch.
- Available Packages
- Name : vsftpd
- Arch : x86_64
- Version : 2.2.2
- Release : 11.el6_4.1
- Size : 151 k
- Repo : base
- Summary : Very Secure Ftp Daemon
- URL : http://vsftpd.beasts.org/
- License : GPLv2 with exceptions
- Description : vsftpd is a Very Secure FTP daemon. It was written completely from
- : scratch.
7、列出软件
列出所有软件:# yum list | less
只列出已经安装的软件:# yum list installed | less
8、查看文件归属
- [root@api test]# yum provides /etc/httpd/conf/httpd.conf
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- httpd-2.2.15-29.el6.centos.x86_64 : Apache HTTP Server
- Repo : base
- Matched from:
- Filename : /etc/httpd/conf/httpd.conf
- httpd-2.2.15-15.el6.centos.1.x86_64 : Apache HTTP Server
- Repo : installed
- Matched from:
- Other : Provides-match: /etc/httpd/conf/httpd.conf
9、检查可用版本更新
# yum check-update
10、系统更新
想确保系统版本最新,打上了所有的安全补丁和二进制软件包更新,只要运行下面这个命令,它会为你的系统安装所有最新的补丁和安全更新版.
# yum update
11、列出所有的可用群组软件包
# yum grouplist
注:如果语言环境设置的是中文,列出的是组句会是中文名称.
12、群组安装
# yum groupinstall 'MySQL Database' 以上是安装mysql数据库。
13、更新群组软件包
# yum groupupdate 'DNS Name Server'
14、移除群组软件包
# yum groupremove 'DNS Name Server'
15、列出启用的Yum软件库
- [root@api test]# yum repolist
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- repo id repo name status
- base CentOS-6 - Base 6,367
- extras CentOS-6 - Extras 14
- updates CentOS-6 - Updates 609
- repolist: 6,990
16、列出所有启用或禁用的yum软件库
# yum repolist all
17、使用特定软件库安装软件
想安装来自某个启用或禁用的软件库的某个软件包,必须在yum命令中使用-enablerepo选项,比如,想安装PhpMyAdmin 3.5.2软件包,只要执行这个命令.
# yum --enablerepo=epel install phpmyadmin
18、交互式Yum shell
- # yum shell
- Loaded plugins: fastestmirror
- Setting up Yum Shell
- > update httpd
- Loading mirror speeds from cached hostfile
- * base: mirrors.sin3.sg.voxel.net
- * epel: ftp.riken.jp
- * extras: mirrors.sin3.sg.voxel.net
- * updates: mirrors.sin3.sg.voxel.net
- Setting up Update Process
- >
19、yum缓存清理
默认情况下,yum将所有软件库中启用软件包的数据,连同每个子目录保存在/var/cache/yum/中,想清除启用软件库中的所有缓存文件,你要定期运行下面这个命令,清理所有缓存内容,并确保没有任何东西在使用不必要的存储空间,我们不想给出下面这个命令的输出结果,因为我们想保持缓存数据的原来样子.
# yum clean all
20、查看yum的历史记录
- [root@api test]# yum history
- Loaded plugins: fastestmirror, security
- ID | Login user | Date and time | Action(s) | Altered
- -------------------------------------------------------------------------------
- 19 | root <root> | 2011-12-19 11:54 | Install | 1
- 18 | root <root> | 2011-11-28 17:18 | I, U | 2
- 17 | root <root> | 2011-11-11 14:26 | Install | 1
- 16 | root <root> | 2011-09-27 17:11 | Install | 1
- 15 | root <root> | 2011-09-23 10:50 | Update | 2
- 14 | root <root> | 2011-09-23 10:48 | Update | 4
- 13 | root <root> | 2011-08-28 11:45 | Update | 1
- 12 | root <root> | 2011-08-21 13:27 | Install | 8
- 11 | root <root> | 2011-08-21 13:19 | Install | 2
- 10 | root <root> | 2011-07-12 16:33 | I, O, U | 43
- 9 | root <root> | 2011-03-12 15:15 | I, U | 3
- 8 | root <root> | 2011-03-12 15:12 | I, U | 13
- 7 | root <root> | 2011-03-06 08:11 | Install | 6
- 6 | root <root> | 2011-03-05 22:55 | Install | 7
- 5 | root <root> | 2011-03-05 22:16 | Install | 1
- 4 | root <root> | 2011-03-05 22:11 | I, U | 10
- 3 | root <root> | 2011-03-05 22:07 | I, U | 9
- 2 | root <root> | 2011-03-05 22:04 | Install | 1
- 1 | System <unset> | 2011-03-05 18:37 | Install | 648
- history list
新闻热点
疑难解答