目录
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