④ RPM 包的删除、更新、查询

目录

1. RPM 的删除

1.1 示列

2. RPM 的升级

3. RPM 的查询

3.1 示列


1. RPM 的删除

rpm {-e|--erase} [-allmatches] [--nodeps] [--test] PACKAGE_NAME
rpm -e [删除选项1 删除选项2 ...][软件名1][软件名2] ...

RPM 包的删除要考虑到依赖关系,所以有些情况下如果只是删除软件而不删除依赖关系依旧会报错,如果要忽略则就需要使用参数  --noscripts 

删除选项说明
-e删除指定的套件
--nodeps不检查依赖关系
--noscripts不运行预安装脚本和后安装脚本
--test只对安装进行测试,并不会实际安装
--allmatches卸载所有匹配指定名称的程序包的各版本

1.1 示列

[root@localhost ~]# rpm -e tree
[root@localhost ~]# tree
-bash: tree: command not found
[root@localhost ~]# rpm -qi tree
package tree is not installed

考虑到软件的依赖关系这就需要使用到参数 --nodeps 来进行卸载。

2. RPM 的升级

rpm {-U|--upgrade} [install-options] PACKAGE_FILE ... ...
rpm {-F|--upgrade} [install-options] PACKAGE_FILE ... ...
rpm -U [升级选项1 升级选项2 ...] [包文件1] [包文件2] ... 

常用的 RPM 选项

选项描述
-U升级或安装指定包文件
-F升级指定的包文件
--oldpackage降级
--force强制升级

升级选项及其说明

升级说明说明升级选项说明
--excludedocs不安装软件包的文档文件--nodeps不检查依赖关系
--force忽略软件包及文件的冲突--noscripts不运行预安装脚本后安装脚本
--ftpport port指定 FTP 的端口号为 port--oldpackage允许 “升级” 到一个老版本
--ftpproxy host用 host 作为 FTP 代理--percent以百分比的形式显示升级安装的进度
--h (or --hash)升级时输出 hash 记号 # --prefix path将软件包升级到由 path 指定的路径下
--ignorearch不校验软件包的结构--replacefiles替换属于其他软件包的文件
--ignoreos不检查软件包运行的操作系统--replacepkgs强制重新升级安装已安装的软件包
--includedocs安装软件包中的文档文件--test只对升级安装进行测试,不实际安装

3. RPM 的查询

rpm {-q|--query} [select-options] [query-options]
rpm -q [查询选项1 查询选项2 ...] <软件名|软件名|文件名>
  • 选择选项
选项描述
-a, --all

查询所有已安装过的包

PACKAGE_NAME查询指定的程序包是否已经安装,及其版本
-f, --file查询指定的文件由哪个程序要安装生成
-p, --pckage用于实现对未安装的程序包指执行查询操作
  • 查询选项
选项描述
-l, --list程序安装生成的所有文件列表
-i, --info程序包相关的信息,版本号、大小、所属的包组等
-c, --configfiles查询指定的程序包提供的配置文件
-d, --docfiles查询指定的程序包提供的文档
-R, --requires查询指定的程序包的依赖关系
--scripts查询程序包自带的脚本片段

3.1 示列

查询一个未安装的程序:

[root@localhost ~]# rpm -qi tree
package tree is not installed

[root@localhost ~]# rpm -qip tree-1.6.0-10.el7.x86_64.rpm
Name        : tree
Version     : 1.6.0
Release     : 10.el7
Architecture: x86_64
Install Date: (not installed)
Group       : Applications/File
Size        : 89505
License     : GPLv2+
Signature   : RSA/SHA256, Fri 04 Jul 2014 01:36:46 AM EDT, Key ID 24c6a8a7f4a80eb5
Source RPM  : tree-1.6.0-10.el7.src.rpm
Build Date  : Mon 09 Jun 2014 03:28:53 PM EDT
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree utility.

查询已经安装的:

[root@localhost ~]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:tree-1.6.0-10.el7                ################################# [100%]
[root@localhost ~]# rpm -qi tree
Name        : tree
Version     : 1.6.0
Release     : 10.el7
Architecture: x86_64
Install Date: Wed 11 Oct 2023 07:03:03 PM EDT
Group       : Applications/File
Size        : 89505
License     : GPLv2+
Signature   : RSA/SHA256, Fri 04 Jul 2014 01:36:46 AM EDT, Key ID 24c6a8a7f4a80eb5
Source RPM  : tree-1.6.0-10.el7.src.rpm
Build Date  : Mon 09 Jun 2014 03:28:53 PM EDT
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree
utility.

查询当前软件的包:

[root@localhost ~]# rpm -q docker-ce
docker-ce-20.10.9-3.el7.x86_64

列出软件把的配置文件

[root@localhost ~]# rpm -qc yum
/etc/logrotate.d/yum
/etc/yum.conf
/etc/yum/version-groups.conf

列出软件包安装或删除运行的shell脚本:

[root@localhost ~]# rpm -q --scripts httpd
preinstall scriptlet (using /bin/sh):
# Add the "apache" group and user
/usr/sbin/groupadd -g 48 -r apache 2> /dev/null || :
/usr/sbin/useradd -c "Apache" -u 48 -g apache \
        -s /sbin/nologin -r -d /usr/share/httpd apache 2> /dev/null || :
postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] ; then
        # Initial installation
        systemctl preset httpd.service htcacheclean.service >/dev/null 2>&1 || :
fi
preuninstall scriptlet (using /bin/sh):

if [ $1 -eq 0 ] ; then
        # Package removal, not upgrade
        systemctl --no-reload disable httpd.service htcacheclean.service > /dev/null 2>&1 || :
        systemctl stop httpd.service htcacheclean.service > /dev/null 2>&1 || :
fi
postuninstall scriptlet (using /bin/sh):

systemctl daemon-reload >/dev/null 2>&1 || :


# Trigger for conversion from SysV, per guidelines at:
# https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd
posttrans scriptlet (using /bin/sh):
test -f /etc/sysconfig/httpd-disable-posttrans || \
  /bin/systemctl try-restart httpd.service htcacheclean.service >/dev/null 2>&1 || :

列出软件依赖的列表:

[root@localhost ~]# rpm -qR tree
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值