一、rpm
二、yum
三、编译安装
一、rpm
1、rpm简介
2、rpm 安装命令 (rpm -ivh --nodeps --force)
3、rpm 卸载 (rpm -e)
4、rpm 查询 (rpm -q -qa -ql -qf)
1、rpm 简介:
rpm:(Redhat Package Manager),可以在Redhat和Suse系统使用
[root@localhost ~] mount /dev/cdrom /mnt // 挂载光驱
[root@localhost ~]# ll /mnt/Packages/ | less
总用量 4264938
-r--r--r--. 2 root root 1564700 10月 18 04:01 389-ds-base-1.2.11.15-46.el6.x86_64.rpm
-r--r--r--. 2 root root 433236 10月 18 03:55 389-ds-base-libs-1.2.11.15-46.el6.i686.rpm
-r--r--r--. 2 root root 428392 10月 18 04:00 389-ds-base-libs-1.2.11.15-46.el6.x86_64.rpm
-r--r--r--. 2 root root 214692 10月 18 04:02 abrt-2.0.8-26.el6.centos.x86_64.rpm
rpm包名构成:
1、包名:abrt
2、版本号:2.0.8-26
3、系统类型:el6 指的是redhat企业版6, centos 指的是在centos上使用
4、x86_64:平台类型。 i686 32位. noarch:32位和64位皆可,没有平台限制
2、rpm 安装命令
-ivh:安装。-i install,安装;-v 可视化;-h 显示安装进度条
--nodeps:在安装或升级一个包之前不进行一个依赖性的检测
--force:强制安装,即使覆盖属于其他包的文件也要安装
-Uvh:升级rpm包
*********************************************************
--force 无法替代 --nodeps
[root@localhost ~]# rpm -ivh /mnt/Packages/amanda-2.6.1p2-8.el6.x86_64.rpm
error: Failed dependencies:
amanda-client = 2.6.1p2-8.el6 is needed by amanda-2.6.1p2-8.el6.x86_64
xinetd is needed by amanda-2.6.1p2-8.el6.x86_64
[root@localhost ~]# rpm -ivh --force /mnt/Packages/amanda-2.6.1p2-8.el6.x86_64.rpm
error: Failed dependencies:
amanda-client = 2.6.1p2-8.el6 is needed by amanda-2.6.1p2-8.el6.x86_64
xinetd is needed by amanda-2.6.1p2-8.el6.x86_64
[root@localhost ~]# rpm -ivh --nodeps /mnt/Packages/amanda-2.6.1p2-8.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:amanda ########################################### [100%]
[root@localhost ~]#
*********************************************************
--force 重新安装rpm包
[root@localhost ~]# rpm -qa | grep vim
vim-common-7.2.411-1.8.el6.x86_64
vim-enhanced-7.2.411-1.8.el6.x86_64
vim-minimal-7.2.411-1.8.el6.x86_64
[root@localhost Packages]# rpm -ivh vim-common-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
package vim-common-2:7.2.411-1.8.el6.x86_64 is already installed
[root@localhost Packages]# rpm -Uvh vim-common-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
package vim-common-2:7.2.411-1.8.el6.x86_64 is already installed
[root@localhost Packages]# rpm -Uvh --force vim-common-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:vim-common ########################################### [100%]
*********************************************************
3、rpm卸载
rpm -e filename // filename由rpm查询功能所查询到的
[root@localhost Packages]# rpm -qa | grep vim
vim-common-7.2.411-1.8.el6.x86_64
vim-enhanced-7.2.411-1.8.el6.x86_64
vim-minimal-7.2.411-1.8.el6.x86_64
[root@localhost Packages]# rpm -e vim-enhanced-7.2.411-1.8.el6.x86_64
[root@localhost Packages]# echo $?
0
[root@localhost Packages]# rpm -ivh vim-enhanced-7.2.411-1.8.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:vim-enhanced ########################################### [100%]
[root@localhost Packages]# rpm -e vim-enhanced // 可以不带版本号
[root@localhost Packages]# echo $?
0
4、rpm 查询
rpm -q vim-enhanced 查询某个包是否安装
rpm -qa | more 查询所有
rpm -qa | grep vim 当前安装过的所有rpm包
rpm -ql vim-enhanced // rpm 所安装的文件
rpm -qf `which wim` 某个文件属于哪个rpm包
[root@localhost Packages]# rpm -qf `which vim`
vim-enhanced-7.2.411-1.8.el6.x86_64
二、yum 工具
1、yum命令
yum list 列出所有可用的rpm包资源:包括安装和未安装的
yum install -y vim
yum remove -y vim
yum update -y vim
yum provides "*/vim" 查询一个命令由哪个包安装来的
yum grouplist 列出所有套件
yum groupinstall -y Desktop " X Window System" 安装桌面环境
yum groupremove -y Desktop " X Window System"
运行以下命令生成缓存
yum clean all
yum makecache
2、创建本地yum源
[root@localhost ~]# mount /dev/cdrom /mnt // 挂载centos6.6 光盘
[root@localhost ~]# vi /etc/yum.repos.d/dvd.repo // 新建 dvd.repo本地yum源文件
[DVD]
name=local dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@localhost ~]# yum list | grep DVD | tail -1 // 验证
zlib-static.x86_64 1.2.3-29.el6 DVD
3、yum 其它用法
a、 安装其它yum源
yum install -y epel-release
rpm -ivh http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm
其他地址:http://www.aminglinux.com/bbs/thread-6721-1-1.html
b、yum只下载不安装
[root@localhost yum.repos.d]# yum install -y yum-plugin-downloadonly.noarch // 首先安装插件
[root@localhost yum.repos.d]# yum reinstall vim --downloadonly --downloaddir=/usr/local/src -y 将vim-enhanced 下载到/usr/local/src 目录下
三、源码包安装
[root@localhost ~]# wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz [root@localhost ~]# tar zxvf httpd-2.2.16.tar.gz [root@localhost ~]# cd httpd-2.2.16
[root@localhost httpd-2.2.16]# ./configure --prefix=/usr/local/apache2
[root@localhost httpd-2.2.16]# make && make install
[root@localhost httpd-2.2.16]# echo $?
0
扩展:
1. 使yum保留安装过的包 http://www.360doc.com/content/11/0218/15/4171006_94080041.shtml
2. 使用网易yum源 http://www.aminglinux.com/bbs/thread-7475-1-1.html
3. 搭建局域网yum源 http://www.aminglinux.com/bbs/thread-7627-1-1.html
4. yum源优先级 http://www.aminglinux.com/bbs/thread-7168-1-1.html
阿铭论坛:http://www.aminglinux.com/bbs/thread-7696-1-1.html
本文出自 “Linux学习笔记” 博客,请务必保留此出处http://genxin.blog.51cto.com/665191/1627297
原文地址:http://genxin.blog.51cto.com/665191/1627297