linux(三十九)linux软件包管理RPM

2023年 10月 11日 81.8k 0

rpm软件包是Linux的各个发行版本中应用最为广泛的软件包格式之一,成为众多Linux发行版公认的软件包管理标准,最早由Red Hat这家公司开发。

 

RPM 套件管理方式的出现,让 Linux 易于安装,升级,间接提升了 Linux 的适用度。

前文中介绍的yum源其实就是rpm的一个升级版,rpm在安装软件的时候,如果缺少依赖,软件安装会失败,而yum源安装会自动安装这个软件需要的所有依赖。因此,我们常用的就是yum而非rpm安装。

 

1:下载rpm包

(1):安装 yum-utils

yum install yum-utils -y

 

(2):查看yum-utils包里的命令

rpm -ql yum-utils
rpm -ql yum-utils |grep yumdownloader

 

(3):使用yumdownloader下载

yumdownloader --resolve 

 

2:安装rpm包

-i : install 安装的意思

-v : 查看更详细的安装信息
-h: 显示安装进度,在安装升级的过程中,以“#”显示安装进度
–force: 强制安装某个软件包,可以用于替换已安装版本或安装旧版本
–nodeps: 安装、升级过程中,不检查与其他软件包的依赖关系

安装这个:

4.png

cd /opt/download/
rpm -ivh firefox-91.13.0-1.el7.centos.x86_64.rpm

执行报错:

[root@VM_0_4_centos download]# rpm -ivh firefox-91.13.0-1.el7.centos.x86_64.rpm
error: Failed dependencies:
       liberation-fonts-common is needed by firefox-91.13.0-1.el7.centos.x86_64
       liberation-sans-fonts is needed by firefox-91.13.0-1.el7.centos.x86_64
       mozilla-filesystem is needed by firefox-91.13.0-1.el7.centos.x86_64
       nspr >= 4.32 is needed by firefox-91.13.0-1.el7.centos.x86_64
       nss >= 3.67 is needed by firefox-91.13.0-1.el7.centos.x86_64
       libatk-1.0.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libcairo-gobject.so.2()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libcairo.so.2()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libgdk-3.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libgdk_pixbuf-2.0.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libgtk-3.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libnss3.so(NSS_3.55)(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libnss3.so(NSS_3.58)(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libpango-1.0.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libpangocairo-1.0.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libpangoft2-1.0.so.0()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXcomposite.so.1()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXcursor.so.1()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXdamage.so.1()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXext.so.6()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXfixes.so.3()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXi.so.6()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64
       libXt.so.6()(64bit) is needed by firefox-91.13.0-1.el7.centos.x86_64

 

这里要是还想继续安装的话,就需要用到我们上边介绍的强制安装的参数了:

rpm -ivh --force --nodeps firefox-91.13.0-1.el7.centos.x86_64.rpm

 

安装成功!

 

3:rpm查看所有已安装的rpm包

-q :仅查询,后面接的软件名称是否有安装

rpm -qa

1.png

我们也可以单独查看是否安装了某个软件,配合搜索命令grep使用

rpm -qa | grep gcc
[root@VM_0_4_centos ~]# rpm -qa | grep gcc
gcc-c++-4.8.5-44.el7.x86_64
libgcc-4.8.5-44.el7.x86_64
gcc-4.8.5-44.el7.x86_64

 

4:查看已安装rpm包信息

-i : install 安装的意思

rpm -qi gcc

2.png

 

5:查看rpm已安装的包

Rpm已安装的包一般都是在/usr/bin/目录下:

3.png

 

6:升级rpm包

rpm -Uvh   # 升级
rpm -Fvh   # 升级

实例:升级firefox:

[root@VM_0_4_centos bin]# cd /opt/download
[root@VM_0_4_centos bin]# rpm -Uvh --force --nodeps firefox-91.13.0-1.el7.centos.x86_64.rpm # 升级不考虑依赖

 

7:删除rpm包

rpm -e 

 

实例:卸载firefox

[root@VM_0_4_centos bin]# cd /usr/bin/
[root@VM_0_4_centos bin]# rpm -e firefox
[root@VM_0_4_centos bin]# ll | grep firefox

 

8:一些常用的RPM命令:

# 安装
 rpm -ivh                       # 直接安装
 rpm --force -ivh          # 忽略报错,强制安装
 rpm -ivh --noscripts    # 在安装过程不执行脚本
 rpm -ivh --replacepkgs  # 覆盖、替换安装
 
 # 在安装过程可能出现以来错误,如A包依赖于B包,那么在A包安装之前,需要先安装好B包
 
 # 查询
 rpm -q telnet                           # 查询指定的包是否安装
 rpm -qa                                   # 列出所有安装过的包
 rpm -qf  /bin/ls               # 查询指定文件来自于那个安装包
 rpm -qif /bin/ls               # 返回软件包的有关信息
 rpm -qlf /bin/ls               # 返回软件包的文件列表
 rpm -qi telnet                          # 查询包元数据
 rpm -ql telnet                          # 获取rpm包中的文件安装的位置
 rpm -qd telnet                         # 查询包相关文档
 rpm -qc bash                           # 查询包配置文件
 rpm -q --scripts bash       # 查询安装、卸载前后执行的脚本
 rpm -q --changelog telnet      # 查询包更新信息
 rpm -qpR             # 查看包依赖关系

 

以上大概就是linux包管理命令RPM的基本使用,有好的额建议,请在下方输入你的评论。

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论