rpm包的管理
- 介绍
rpm用于互联网下载包的打包及安装工具,它包含在某些Linux分发版中。它生成具有.RPM扩展名的文件。RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写,类似windows的 setup.exe,这一文件格式名称虽然打上了RedHat的标志,但理念是通用的。
Linux的分发版本都有采用(suse,redhat,centos 等等),可以算是公认的行业标准了。 - rpm包的简单查询指令
查询已安装的rpm列表 rpm -qa|grep xx
[root@localhost100 ~]# rpm -qa |grep firefox
firefox-68.10.0-1.el7.centos.x86_64
[root@localhost100 ~]#
- rpm包名基本格式
一个rpm包名:firefox-60.2.2-1.el7.centos.x86_64
名称:firefox
版本号:60.2.2-1
适用操作系统:el7.centos.x86 64
表示centos7.x的64位系统
如果是i686、i386表示32位系统,noarch表示通用。 - rpm包的其它查询指令:
(1)rpm -qa:查询所安装的所有rpm软件包 rpm -qa |more
rpm -qa | grep X
rpm -qa | grep firefox
[root@localhost100 ~]# rpm -qa | grep firefox
firefox-91.8.0-1.el7.centos.x86_64
(2)rpm -q软件包名:查询软件包是否安装
[root@localhost100 ~]# rpm -q firefox
firefox-68.10.0-1.el7.centos.x86_64
(3)rpm -qi软件包名 :查询软件包信息
[root@localhost100 ~]# rpm -qi firefox
Name : firefox
Version : 68.10.0
Release : 1.el7.centos
Architecture: x86_64
Install Date: 2022年03月10日 星期四 12时14分37秒
Group : Unspecified
Size : 241030932
License : MPLv1.1 or GPLv2+ or LGPLv2+
Signature : RSA/SHA256, 2020年07月09日 星期四 00时21分14秒, Key ID 24c6a8a7f4a80eb5
Source RPM : firefox-68.10.0-1.el7.centos.src.rpm
Build Date : 2020年07月08日 星期三 02时51分10秒
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : https://www.mozilla.org/firefox/
Summary : Mozilla Firefox Web browser
Description :
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.
[root@localhost100 ~]#
(4)rpm -ql软件包名:查询软件包中的文件比如:rpm -ql firefox
[root@localhost100 ~]# rpm -ql firefox
(5)rpm -qf文件全路径名查询文件所属的软件包
[root@localhost100 ~]# rpm -qf /etc/passwd
setup-2.8.71-11.el7.noarch
[root@localhost100 ~]#
- 卸载rpm包:
基本语法
rpm -e 包的名称
细节讨论
(1)如果其它软件包依赖于您要卸载的软件包,卸载时则会产生错误信息。如: r p m − e f o o r e m o v i n g t h e s e p a c k a g e s w o u l d b r e a k d e p e n d e n c i e s : f o o i s n e e d e d b y b a r − 1.0 − 1 ( 2 ) 如 果 我 们 就 是 要 删 除 f o o 这 个 r p m 包 , 可 以 增 加 参 数 − − n o d e p s , 就 可 以 强 制 删 除 , 但 是 一 般 不 推 荐 这 样 做 , 因 为 依 赖 于 该 软 件 包 的 程 序 可 能 无 法 运 行 如 : rpm-e foo removing these packages would break dependencies:foo is needed by bar-1.0-1 (2)如果我们就是要删除foo这个rpm包,可以增加参数--nodeps,就可以强制删除,但是一般不推荐 这样做,因为依赖于该软件包的程序可能无法运行如: rpm−efooremovingthesepackageswouldbreakdependencies:fooisneededbybar−1.0−1(2)如果我们就是要删除foo这个rpm包,可以增加参数−−nodeps,就可以强制删除,但是一般不推荐这样做,因为依赖于该软件包的程序可能无法运行如: rpm -e–nodeps foo
6. 安装rpm包
基本语法
rpm -ivh 包全路径名称
参数说明 i=install 安装 v=verbose提示 h=hash 进度条
应用实例:演示卸载和安装firefox浏览器
(1)卸载
[root@localhost100 ~]# rpm -e firefox
[root@localhost100 ~]# rpm -q firefox
未安装软件包 firefox
[root@localhost100 ~]#
(2)安装
找到包全路径名称
复制到opt目录下
[root@localhost100 ~]# rpm -ivh /opt/firefox-68.10.0-1.el7.centos.x86_64.rpm
yum
- 介绍:
Yum 是一个Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包。 - yum的基本指令
查询yum服务器是否有需要安装的软件
yum list |grep xx软件列表
[root@localhost100 ~]# yum list |grep firefox
firefox.x86_64 68.10.0-1.el7.centos @anaconda
firefox.i686 91.8.0-1.el7.centos updates
firefox.x86_64 91.8.0-1.el7.centos updates
[root@localhost100 ~]#
安装指定的yum包
yum install xxx 下载安装
yum应用实例:
案例:请使用yum的方式来安装firefox
[root@localhost100 ~]# yum install firefox
t@localhost100 ~]# yum install firefox
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 firefox.x86_64.0.91.8.0-1.el7.centos 将被 安装
--> 正在处理依赖关系 nss >= 3.67,它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 nspr >= 4.32,它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 libnss3.so(NSS_3.58)(64bit),它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 libnss3.so(NSS_3.55)(64bit),它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 libnss3.so(NSS_3.52)(64bit),它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 libnss3.so(NSS_3.47)(64bit),它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 libnss3.so(NSS_3.45)(64bit),它被软件包 firefox-91.8.0-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 nspr.x86_64.0.4.21.0-1.el7 将被 升级
---> 软件包 nspr.x86_64.0.4.32.0-1.el7_9 将被 更新
---> 软件包 nss.x86_64.0.3.44.0-7.el7_7 将被 升级
--> 正在处理依赖关系 nss = 3.44.0-7.el7_7,它被软件包 nss-sysinit-3.44.0-7.el7_7.x86_64 需要
--> 正在处理依赖关系 nss(x86-64) = 3.44.0-7.el7_7,它被软件包 nss-tools-3.44.0-7.el7_7.x86_64 需要
---> 软件包 nss.x86_64.0.3.67.0-4.el7_9 将被 更新
--> 正在处理依赖关系 nss-util >= 3.67.0-1,它被软件包 nss-3.67.0-4.el7_9.x86_64 需要
--> 正在处理依赖关系 nss-softokn(x86-64) >= 3.67.0-1,它被软件包 nss-3.67.0-4.el7_9.x86_64 需要
--> 正在处理依赖关系 libnssutil3.so(NSSUTIL_3.59)(64bit),它被软件包 nss-3.67.0-4.el7_9.x86_64 需要
--> 正在检查事务
---> 软件包 nss-softokn.x86_64.0.3.44.0-8.el7_7 将被 升级
---> 软件包 nss-softokn.x86_64.0.3.67.0-3.el7_9 将被 更新
--> 正在处理依赖关系 nss-softokn-freebl(x86-64) >= 3.67.0-3.el7_9,它被软件包 nss-softokn-3.67.0-3.el7_9.x86_64 需要
---> 软件包 nss-sysinit.x86_64.0.3.44.0-7.el7_7 将被 升级
---> 软件包 nss-sysinit.x86_64.0.3.67.0-4.el7_9 将被 更新
---> 软件包 nss-tools.x86_64.0.3.44.0-7.el7_7 将被 升级
---> 软件包 nss-tools.x86_64.0.3.67.0-4.el7_9 将被 更新
---> 软件包 nss-util.x86_64.0.3.44.0-4.el7_7 将被 升级
---> 软件包 nss-util.x86_64.0.3.67.0-1.el7_9 将被 更新
--> 正在检查事务
---> 软件包 nss-softokn-freebl.x86_64.0.3.44.0-8.el7_7 将被 升级
---> 软件包 nss-softokn-freebl.x86_64.0.3.67.0-3.el7_9 将被 更新
--> 解决依赖关系完成
依赖关系解决
=====================================================================================================================================
Package 架构 版本 源 大小
=====================================================================================================================================
正在安装:
firefox x86_64 91.8.0-1.el7.centos updates 106 M
为依赖而更新:
nspr x86_64 4.32.0-1.el7_9 updates 127 k
nss x86_64 3.67.0-4.el7_9 updates 882 k
nss-softokn x86_64 3.67.0-3.el7_9 updates 358 k
nss-softokn-freebl x86_64 3.67.0-3.el7_9 updates 337 k
nss-sysinit x86_64 3.67.0-4.el7_9 updates 66 k
nss-tools x86_64 3.67.0-4.el7_9 updates 549 k
nss-util x86_64 3.67.0-1.el7_9 updates 79 k
事务概要
=====================================================================================================================================
安装 1 软件包
升级 ( 7 依赖软件包)
总计:109 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在更新 : nspr-4.32.0-1.el7_9.x86_64 1/15
正在更新 : nss-util-3.67.0-1.el7_9.x86_64 2/15
正在更新 : nss-softokn-freebl-3.67.0-3.el7_9.x86_64 3/15
正在更新 : nss-softokn-3.67.0-3.el7_9.x86_64 4/15
正在更新 : nss-3.67.0-4.el7_9.x86_64 5/15
正在更新 : nss-sysinit-3.67.0-4.el7_9.x86_64 6/15
正在安装 : firefox-91.8.0-1.el7.centos.x86_64 7/15
正在更新 : nss-tools-3.67.0-4.el7_9.x86_64 8/15
清理 : nss-tools-3.44.0-7.el7_7.x86_64 9/15
清理 : nss-3.44.0-7.el7_7.x86_64 10/15
清理 : nss-sysinit-3.44.0-7.el7_7.x86_64 11/15
清理 : nss-softokn-3.44.0-8.el7_7.x86_64 12/15
清理 : nss-softokn-freebl-3.44.0-8.el7_7.x86_64 13/15
清理 : nss-util-3.44.0-4.el7_7.x86_64 14/15
清理 : nspr-4.21.0-1.el7.x86_64 15/15
验证中 : firefox-91.8.0-1.el7.centos.x86_64 1/15
验证中 : nss-sysinit-3.67.0-4.el7_9.x86_64 2/15
验证中 : nss-3.67.0-4.el7_9.x86_64 3/15
验证中 : nss-util-3.67.0-1.el7_9.x86_64 4/15
验证中 : nspr-4.32.0-1.el7_9.x86_64 5/15
验证中 : nss-tools-3.67.0-4.el7_9.x86_64 6/15
验证中 : nss-softokn-freebl-3.67.0-3.el7_9.x86_64 7/15
验证中 : nss-softokn-3.67.0-3.el7_9.x86_64 8/15
验证中 : nss-sysinit-3.44.0-7.el7_7.x86_64 9/15
验证中 : nss-tools-3.44.0-7.el7_7.x86_64 10/15
验证中 : nss-3.44.0-7.el7_7.x86_64 11/15
验证中 : nss-util-3.44.0-4.el7_7.x86_64 12/15
验证中 : nspr-4.21.0-1.el7.x86_64 13/15
验证中 : nss-softokn-freebl-3.44.0-8.el7_7.x86_64 14/15
验证中 : nss-softokn-3.44.0-8.el7_7.x86_64 15/15
已安装:
firefox.x86_64 0:91.8.0-1.el7.centos
作为依赖被升级:
nspr.x86_64 0:4.32.0-1.el7_9 nss.x86_64 0:3.67.0-4.el7_9 nss-softokn.x86_64 0:3.67.0-3.el7_9
nss-softokn-freebl.x86_64 0:3.67.0-3.el7_9 nss-sysinit.x86_64 0:3.67.0-4.el7_9 nss-tools.x86_64 0:3.67.0-4.el7_9
nss-util.x86_64 0:3.67.0-1.el7_9
完毕!
[root@localhost100 ~]#