summerinsist 2017-10-29
rpm,RedHat Package Manager,即为红帽公司为RHEL开发的专用包管理器,后来更改为RPM Package Manager,类似于GNU项目,使用递归命名,GNU's Not Unix.
-v 显示附加信息 -vv 显示调试信息 --root 让RPM将指定的路径做为"根目录",这样预安装程序和后安 装程序都会安装到这个目录下 --dbpath 设置RPM 资料库存所在的路径为
1.查询指定的包是否安装,比如tree
[root@localhost tmp]#rpm -q tree tree-1.5.3-3.el6.x86_64 #PKG为包全名 rpm -q PKG
2.查询指定文件来自于那个安装包,以/bin/ls文件为例
[root@localhost Packages]#rpm -qf /bin/ls coreutils-8.4-43.el6.x86_64 rpm -qf /PATH/TO/FILE
3.查询包更新信息
[root@localhost Packages]#rpm -q --changelog tree * Thu Nov 27 2014 Tim Waugh <[email protected]> - 1.5.3-3 - Handle large UID/GID values (bug #1110559). * Wed Mar 03 2010 Tim Waugh <[email protected]> 1.5.3-2 - Added comments to all patches. ... rpm -q --changelog PKG
4.查询包元数据
[root@localhost Packages]#rpm -qi tree Name : tree Relocations: (not relocatable) Version : 1.5.3 Vendor: CentOS Release : 3.el6 Build Date: Wed 14 Jan 2015 08:21:02 PM CST Install Date: Sat 25 Mar 2017 04:17:05 AM CST Build Host: c6b9.bsys.dev.centos.org Group : Applications/File Source RPM: tree-1.5.3-3.el6.src.rpm ... rpm -qi PKG
5.查询包生成的所有文件
[root@localhost Packages]#rpm -ql tree /usr/bin/tree /usr/share/doc/tree-1.5.3 /usr/share/doc/tree-1.5.3/LICENSE /usr/share/doc/tree-1.5.3/README /usr/share/man/man1/tree.1.gz rpm -ql PKG
6.查询包相关文档
[root@localhost Packages]#rpm -qd tree /usr/share/doc/tree-1.5.3/LICENSE /usr/share/doc/tree-1.5.3/README /usr/share/man/man1/tree.1.gz rpm -qd PKG
7.查询包配置文件
[root@localhost Packages]#rpm -qc bash /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc rpm -qc PKG
8.查询安装、卸载前后执行的脚本
[root@localhost Packages]#rpm -q --scripts bash postinstall scriptlet (using <lua>): bashfound = false; shfound = false; f = io.open("/etc/shells", "r"); if f == nil then ... #有四个时间点可以执行脚本程序:包安装前、安装后、卸载前以及卸载后
1.安装rpm程序包,在安装过程,后面的PKG必须是文件路径
[root@localhost Packages]#rpm -ivh gcc- ## 按两次tab键 gcc-4.4.7-17.el6.x86_64.rpm gcc-java-4.4.7-17.el6.x86_64.rpm gcc-c++-4.4.7-17.el6.x86_64.rpm gcc-objc-4.4.7-17.el6.x86_64.rpm gcc-gfortran-4.4.7-17.el6.x86_64.rpm gcc-objc++-4.4.7-17.el6.x86_64.rpm gcc-gnat-4.4.7-17.el6.x86_64.rpm #安装 [root@localhost Packages]#rpm -ivh gcc-4.4.7-17.el6.x86_64.rpm #/PATH/TO/PKG为rpm包的路径 rpm -ivh /PATH/TO/PKG
2.在安装过程不执行脚本
[root@localhost Packages]#rpm -ivh --noscripts tree-1.5.3-3.el6.x86_64.rpm warning: tree-1.5.3-3.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:tree ########################################### [100%] rpm -ivh --noscripts PKG
3.覆盖、替换安装
[root@localhost Packages]#rpm -ivh --replacepkgs tree-1.5.3-3.el6.x86_64.rpm warning: tree-1.5.3-3.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing... ########################################### [100%] 1:tree ########################################### [100%] rpm -ivh --replacepkgs PKG
在安装过程可能出现以来错误,如A包依赖于B包,那么在A包安装之前,需要先安装好B包
4.详细选项
选项 | 含义 |
---|---|
-h | 安装时以#显示安装进度 |
--percent | 以百分比的形式输出安装的进度 |
--test | 测试安装 |
--replacepkgs | 替换属于其它软件包的文件 |
--force | 忽略软件包及文件的冲突 |
--noscripts | 不运行预安装和后安装脚本 |
--ignorearch | 不校验软件包的结构 |
--ignoreos | 不检查软件包运行的操作系统 |
--nodeps | 不检查依赖性关系 |
1.一般卸载
[root@localhost Packages]#rpm -e gcc rpm -e PKG
2.不执行脚本卸载
[root@localhost Packages]#rpm -e --noscripts tree rpm -e --noscripts PKG
[root@localhost Packages]#rpm -Uvh tree-1.5.3-3.el6.x86_64.rpm rpm -Uvh PKG 或 rpm -Fvh PKG
-U和-F选项均可以升级一个包.但是,旧包不存在时,-U选项会安装新包,而-F选项不安装新包。