yum软件包管理
Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora、RedHat、CentOS中的Shell前端软件包管理器,基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包。下面总结下yum的常用参数。
1、yum安装软件包
1#yum install curl 或
2#yum -y install curl 或
不加y参数时是交互式的安装,需要按提示确认后才能安装,而加-y是静默模式,直接进行安装。
2、yum移除软件包
完全移除软件包及所有依赖包
1#yum remove curl 或
2#yum -y remove curl
3、yum更新软件包
1# yum update mysql
4、列出软件包
使用list函数,可搜索带名称的特定软件包。比如说,想搜索一个名为openssh的软件包,使用该命令。
1# yum list openssh
2Loaded plugins: fastestmirror
3Loading mirror speeds from cached hostfile
4* base: mirror.neu.edu.cn
5* epel: mirror.neu.edu.cn
6* extras: mirror.neu.edu.cn
7* rpmforge: mirror.nl.leaseweb.net
8* updates: mirror.nus.edu.sg
9Installed Packages
10openssh.i386 4.3p2-72.el5_6.3 installed
11Available Packages 4.3p2-82.el5 base
想让你的搜索更精确,明确软件包名称的版本,如果你知道的话。比如说,想搜索软件包的特定版本openssh-4.3p2 ,使用该命令。
1# yum list openssh-4.3p2
5、Yum搜索软件包
要是你不记得软件包的确切名称,那么可以使用search或search all,搜索与指定软件包的名称相匹配的所有可用软件包。比如说,想搜索与vsftpd这个单词匹配的所有软件包。
1[root@api test]# yum search vsftpd
2Loaded plugins: fastestmirror, security
3Determining fastest mirrors
4 * base: mirrors.yun-idc.com
5 * extras: mirrors.yun-idc.com
6 * updates: mirrors.yun-idc.com
7base | 3.7 kB 00:00
8extras | 3.4 kB 00:00
9updates | 3.4 kB 00:00
10updates/primary_db | 2.1 MB 00:02
11=============================== N/S Matched: vsftpd ===================================
12vsftpd.x86_64 : Very Secure Ftp Daemon
13 Name and summary matches only, use "search all" for everything.
14[root@api test]# yum search all vsftpd
15Loaded plugins: fastestmirror, security
16Loading mirror speeds from cached hostfile
17 * base: mirrors.yun-idc.com
18 * extras: mirrors.yun-idc.com
19 * updates: mirrors.yun-idc.com
20==============================================Matched: vsftpd ==========================
21vsftpd.x86_64 : Very Secure Ftp Daemon
6、Yum获取软件包信息
假设你想在安装软件包之前先知道它的信息。想获得某软件包的信息,只要执行下面这个命令。
1[root@api test]# yum info vsftpd
2Loaded plugins: fastestmirror, security
3Loading mirror speeds from cached hostfile
4 * base: mirrors.yun-idc.com
5 * extras: mirrors.yun-idc.com
6 * updates: mirrors.yun-idc.com
7Installed Packages
8Name : vsftpd
9Arch : x86_64
10Version : 2.2.2
11Release : 11.el6
12Size : 331 k
13Repo : installed
14From repo : anaconda-CentOS-201207061011.x86_64
15Summary : Very Secure Ftp Daemon
16URL : http://vsftpd.beasts.org/
17License : GPLv2 with exceptions
18Description : vsftpd is a Very Secure FTP daemon. It was written completely from
19 : scratch.
20Available Packages
21Name : vsftpd
22Arch : x86_64
23Version : 2.2.2
24Release : 11.el6_4.1
25Size : 151 k
26Repo : base
27Summary : Very Secure Ftp Daemon
28URL : http://vsftpd.beasts.org/
29License : GPLv2 with exceptions
30Description : vsftpd is a Very Secure FTP daemon. It was written completely from
31 : scratch.
7、列出软件
1列出所有软件
2# yum list | less
3只列出已经安装的软件
4# yum list installed | less
8、查看文件归属
1[root@api test]# yum provides /etc/httpd/conf/httpd.conf
2Loaded plugins: fastestmirror, security
3Loading mirror speeds from cached hostfile
4 * base: mirrors.yun-idc.com
5 * extras: mirrors.yun-idc.com
6 * updates: mirrors.yun-idc.com
7httpd-2.2.15-29.el6.centos.x86_64 : Apache HTTP Server
8Repo : base
9Matched from:
10Filename : /etc/httpd/conf/httpd.conf
11httpd-2.2.15-15.el6.centos.1.x86_64 : Apache HTTP Server
12Repo : installed
13Matched from:
14Other : Provides-match: /etc/httpd/conf/httpd.conf
9、检查可用版本更新
1# yum check-update
10、系统更新
想确保系统版本最新,打上了所有的安全补丁和二进制软件包更新,只要运行下面这个命令。它会为你的系统安装所有最新的补丁和安全更新版。
1# yum update
11、列出所有的可用群组软件包
1# yum grouplist
注:如果语言环境设置的是中文,列出的是组句会是中文名称。
12、群组安装
1# yum groupinstall 'MySQL Database'
以上是安装mysql数据库。
13、更新群组软件包
1# yum groupupdate 'DNS Name Server'
14、移除群组软件包
1# yum groupremove 'DNS Name Server'
15、列出启用的Yum软件库
1[root@api test]# yum repolist
2Loaded plugins: fastestmirror, security
3Loading mirror speeds from cached hostfile
4 * base: mirrors.yun-idc.com
5 * extras: mirrors.yun-idc.com
6 * updates: mirrors.yun-idc.com
7repo id repo name status
8base CentOS-6 - Base 6,367
9extras CentOS-6 - Extras 14
10updates CentOS-6 - Updates 609
11repolist: 6,990
16、列出所有启用或禁用的yum软件库
1# yum repolist all
17、使用特定软件库安装软件
想安装来自某个启用或禁用的软件库的某个软件包,必须在yum命令中使用-enablerepo选项。比如,想安装PhpMyAdmin 3.5.2软件包,只要执行这个命令。
1# yum --enablerepo=epel install phpmyadmin
18、交互式Yum shell
1# yum shell
2Loaded plugins: fastestmirror
3Setting up Yum Shell
4> update httpd
5Loading mirror speeds from cached hostfile
6* base: mirrors.sin3.sg.voxel.net
7* epel: ftp.riken.jp
8* extras: mirrors.sin3.sg.voxel.net
9* updates: mirrors.sin3.sg.voxel.net
10Setting up Update Process
11>
19、yum缓存清理
默认情况下,yum将所有软件库中启用软件包的数据,连同每个子目录保存在/var/cache/yum/中,想清除启用软件库中的所有缓存文件,你要定期运行下面这个命令,清理所有缓存内容,并确保没有任何东西在使用不必要的存储空间。我们不想给出下面这个命令的输出结果,因为我们想保持缓存数据的原来样子。
1# yum clean all
20、查看yum的历史记录
1[root@api test]# yum history
2Loaded plugins: fastestmirror, security
3ID | Login user | Date and time | Action(s) | Altered
4-------------------------------------------------------------------------------
5 19 | root <root> | 2011-12-19 11:54 | Install | 1
6 18 | root <root> | 2011-11-28 17:18 | I, U | 2
7 17 | root <root> | 2011-11-11 14:26 | Install | 1
8 16 | root <root> | 2011-09-27 17:11 | Install | 1
9 15 | root <root> | 2011-09-23 10:50 | Update | 2
10 14 | root <root> | 2011-09-23 10:48 | Update | 4
11 13 | root <root> | 2011-08-28 11:45 | Update | 1
12 12 | root <root> | 2011-08-21 13:27 | Install | 8
13 11 | root <root> | 2011-08-21 13:19 | Install | 2
14 10 | root <root> | 2011-07-12 16:33 | I, O, U | 43
15 9 | root <root> | 2011-03-12 15:15 | I, U | 3
16 8 | root <root> | 2011-03-12 15:12 | I, U | 13
17 7 | root <root> | 2011-03-06 08:11 | Install | 6
18 6 | root <root> | 2011-03-05 22:55 | Install | 7
19 5 | root <root> | 2011-03-05 22:16 | Install | 1
20 4 | root <root> | 2011-03-05 22:11 | I, U | 10
21 3 | root <root> | 2011-03-05 22:07 | I, U | 9
22 2 | root <root> | 2011-03-05 22:04 | Install | 1
23 1 | System <unset> | 2011-03-05 18:37 | Install | 648
24history list
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/yum-packets-manager/3101.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.