一、官方文档 rpm命令man文档如下:
NAME
rpm - RPM Package Manager
SYNOPSIS
QUERYING AND VERIFYING PACKAGES:
rpm {-q|--query} [select-options] [query-options]
rpm {-V|--verify} [select-options] [verify-options]
INSTALLING, UPGRADING, AND REMOVING PACKAGES:
rpm {-i|--install} [install-options] PACKAGE_FILE ...
rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...
rpm {-F|--freshen} [install-options] PACKAGE_FILE ...
rpm {-e|--erase} [--allmatches] [--justdb] [--nodeps] [--noscripts]
[--notriggers] [--test] PACKAGE_NAME ...
二、常用命令总结: 安装:rpm -i | --install PACKAGE_FILE … 卸载:rpm -e | --erase PACKAGE_FILE … 升级:rpm -U | --update PACKAGE_FILE … 查询:rpm -q | --query [select-options] [query-options] 校验:rpm -V | --verify PACKAGE_FILE …
[root@linux4 Packages]
zsh-5.0.2-34.el7_8.2.x86_64.rpm zsh-html-5.0.2-34.el7_8.2.x86_64.rpm
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
Preparing...
package zsh-5.0.2-34.el7_8.2.x86_64 is already installed
[root@linux4 Packages]
zsh-5.0.2-34.el7_8.2.x86_64
[root@linux4 Packages]
Name : zsh
Version : 5.0.2
Release : 34.el7_8.2
Architecture: x86_64
Install Date: Wed 21 Sep 2022 03:16:05 PM CST
Group : System Environment/Shells
Size : 5860430
License : MIT
Signature : RSA/SHA256, Wed 08 Apr 2020 10:41:00 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : zsh-5.0.2-34.el7_8.2.src.rpm
Build Date : Tue 07 Apr 2020 10:38:13 PM CST
Build Host : x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://zsh.sourceforge.net/
Summary : Powerful interactive shell
Description :
The zsh shell is a command interpreter usable as an interactive login
shell and as a shell script command processor. Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements. Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.
[root@linux4 Packages]
[root@linux4 Packages]
[root@linux4 Packages]
三、各命令详解 1、安装 ?命令:rpm {-i|–install} [install-options] PACKAGE_FILE … ?文档:
rpm {-i|--install} [install-options] PACKAGE_FILE ...
install-options
[--allfiles] [--badreloc] [--excludepath OLDPATH]
[--excludedocs] [--force] [-h,--hash]
[--ignoresize] [--ignorearch] [--ignoreos]
[--includedocs] [--justdb] [--nocollections]
[--nodeps] [--nodigest] [--nosignature] [--noplugins]
[--noorder] [--noscripts] [--notriggers]
[--oldpackage] [--percent] [--prefix NEWPATH]
[--relocate OLDPATH=NEWPATH]
[--replacefiles] [--replacepkgs]
[--test]
??[install-options] ???-h: 输出进度条,每个#显示2%的进度 ???--test: 测试安装,不执行安装,仅检查并报告依赖关系及冲突 ???--nodeps: 不检查依赖 ???--force: 同replacepkgs ???--replacepkgs: 即使包已存在,也要执行安装,即覆盖安装 ???--justdb: 只更新数据库 ???--nosignature: 不检查签名信息 ???--nodigest: 不检查完整性信息 ???--prefix NEWPATH: 指定路径安装
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
Preparing...
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
Preparing...
package zsh-5.0.2-34.el7_8.2.x86_64 is already installed
[root@linux4 Packages]
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
[root@linux4 Packages]
error: package zsh is not relocatable
[root@linux4 Packages]
2、升级 ?命令:rpm {-U|–upgrade} [install-options] PACKAGE_FILE … 升级或安装 ????rpm {-F|–freshen} [install-options] PACKAGE_FILE … 只升级 ?文档:同install ??--oldpackage: 降级 ??--force: 强制升级
3、查询 ?命令:rpm {-q|–query} [select-options] [query-options] ?文档:
select-options
[PACKAGE_NAME] [-a,--all] [-f,--file FILE]
[-g,--group GROUP] {-p,--package PACKAGE_FILE]
[--hdrid SHA1] [--pkgid MD5] [--tid TID]
[--querybynumber HDRNUM] [--triggeredby PACKAGE_NAME]
[--whatprovides CAPABILITY] [--whatrequires CAPABILITY]
query-options
[--changelog] [-c,--configfiles] [--conflicts]
[-d,--docfiles] [--dump] [--filesbypkg] [-i,--info]
[--last] [-l,--list] [--obsoletes] [--provides]
[--qf,--queryformat QUERYFMT] [-R,--requires]
[--scripts] [-s,--state] [--triggers,--triggerscripts]
??[select-options] ???PACKAGE_NAME: 查询指定的包是否被安装 ???-a|–all: 查询所有安装的包,通常会配合grep使用 ???-f|–file:查询指定文件由哪个程序包安装生成 ???-p|–package PACKAGE_FILE: 查询未安装的程序包 ??[query-options] ???--changelog:查询rpm包的changelog ???-c|–configfiles:查询rpm包的配置文件信息 ???-d|–docfiles:查询rpm包指定的文档 ???-i|–info: 查询rpm包相关信息,如版本号、大小等 ???-l|–list:程序包生成的文件列表 ???-R|–requires:查询程序包的依赖关系 ???--scripts:查询程序包自带的脚本文件
[root@linux4 Packages]
zsh-5.0.2-34.el7_8.2.x86_64
[root@linux4 Packages]
coreutils-8.22-24.el7.x86_64
[root@linux4 Packages]
zlib-static-1.2.7-18.el7.x86_64
[root@linux4 Packages]
aether-util-1.13.1-13.el7.noarch
firewalld-0.6.3-11.el7.noarch
atinject-tck-1-13.20100611svn86.el7.noarch
perl-Convert-ASN1-0.26-4.el7.noarch
......
[root@linux4 Packages]
mha4mysql-node-0.58-0.el7.centos.noarch
mha4mysql-manager-0.58-0.el7.centos.noarch
[root@linux4 Packages]
package zsh-5.0.2-34.el7_8.2.x86_64.rpm is not installed
[root@linux4 Packages]
* Tue Mar 03 2020 Kamil Dudka <kdudka@redhat.com> - 5.0.2-34.el7_8.2
- improve printing of error messages introduced by the fix of CVE-2019-20044
* Mon Feb 24 2020 Kamil Dudka <kdudka@redhat.com> - 5.0.2-34.el7_8.1
- drop privileges securely when unsetting PRIVILEGED option (CVE-2019-20044)
......
[root@linux4 Packages]
/etc/skel/.zshrc
/etc/zlogin
/etc/zlogout
/etc/zprofile
/etc/zshenv
/etc/zshrc
[root@linux4 Packages]
/usr/share/doc/zsh-5.0.2/BUGS
/usr/share/doc/zsh-5.0.2/CONTRIBUTORS
/usr/share/doc/zsh-5.0.2/FAQ
/usr/share/doc/zsh-5.0.2/FEATURES
/usr/share/doc/zsh-5.0.2/LICENCE
/usr/share/doc/zsh-5.0.2/MACHINES
/usr/share/doc/zsh-5.0.2/NEWS
/usr/share/doc/zsh-5.0.2/README
/usr/share/doc/zsh-5.0.2/completion-style-guide
/usr/share/doc/zsh-5.0.2/zsh-development-guide
[root@linux4 Packages]
Name : zsh
Version : 5.0.2
Release : 34.el7_8.2
Architecture: x86_64
Install Date: Wed 21 Sep 2022 04:50:02 PM CST
Group : System Environment/Shells
Size : 5860430
License : MIT
Signature : RSA/SHA256, Wed 08 Apr 2020 10:41:00 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : zsh-5.0.2-34.el7_8.2.src.rpm
Build Date : Tue 07 Apr 2020 10:38:13 PM CST
Build Host : x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://zsh.sourceforge.net/
Summary : Powerful interactive shell
Description :
The zsh shell is a command interpreter usable as an interactive login
shell and as a shell script command processor. Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements. Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.
[root@linux4 Packages]
/bin/zsh
/etc/skel/.zshrc
/etc/zlogin
/etc/zlogout
/etc/zprofile
/etc/zshenv
/etc/zshrc
/usr/lib64/zsh
/usr/lib64/zsh/5.0.2
/usr/lib64/zsh/5.0.2/zsh
/usr/lib64/zsh/5.0.2/zsh/attr.so
/usr/lib64/zsh/5.0.2/zsh/cap.so
/usr/lib64/zsh/5.0.2/zsh/clone.so
/usr/lib64/zsh/5.0.2/zsh/compctl.so
/usr/lib64/zsh/5.0.2/zsh/complete.so
/usr/lib64/zsh/5.0.2/zsh/complist.so
[root@linux4 Packages]
/bin/sh
/bin/zsh
/sbin/install-info
config(zsh) = 5.0.2-34.el7_8.2
coreutils
grep
grep
libc.so.6()(64bit)
libc.so.6(GLIBC_2.11)(64bit)
libm.so.6()(64bit)
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1
......
[root@linux4 Packages]
postinstall scriptlet (using /bin/sh):
if [ ! -f /etc/shells ] ; then
echo "/bin/zsh" > /etc/shells
else
grep -q "^/bin/zsh$" /etc/shells || echo "/bin/zsh" >> /etc/shells
fi
if [ -f /usr/share/info/zsh.info.gz ]; then
/sbin/install-info /usr/share/info/zsh.info.gz /usr/share/info/dir \
--entry="* zsh: (zsh). An enhanced bourne shell."
fi
:
preuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ] ; then
if [ -f /usr/share/info/zsh.info.gz ]; then
/sbin/install-info --delete /usr/share/info/zsh.info.gz /usr/share/info/dir \
--entry="* zsh: (zsh). An enhanced bourne shell."
fi
fi
:
postuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ] ; then
if [ -f /etc/shells ] ; then
TmpFile=`/bin/mktemp /tmp/.zshrpmXXXXXX`
grep -v '^/bin/zsh$' /etc/shells > $TmpFile
cp -f $TmpFile /etc/shells
rm -f $TmpFile
fi
fi
[root@linux4 Packages]
4、卸载 ?命令:rpm {-e|–erase} [–allmatches] [–justdb] [–nodeps] [–noscripts] [–notriggers] [–test] PACKAGE_NAME … ??--allmatches: 卸载所有匹配指定名称的程序包的各版本 ??--nodeps:忽略依赖关系 ??--test:测试卸载,不真的执行
[root@linux4 Packages]
[root@linux4 Packages]
zsh-5.0.2-34.el7_8.2.x86_64
[root@linux4 Packages]
[root@linux4 Packages]
package zsh is not installed
5、校验 ?命令:rpm {-V|–verify} [select-options] [verify-options] ?文档:
verify-options
[--nodeps] [--nofiles] [--noscripts]
[--nodigest] [--nosignature]
[--nolinkto] [--nofiledigest] [--nosize] [--nouser]
[--nogroup] [--nomtime] [--nomode] [--nordev]
[--nocaps] [--noconfig] [--noghost]
?示例:
[root@linux4 Packages]
Preparing...
Updating / installing...
1:zsh-5.0.2-34.el7_8.2
[root@linux4 Packages]
[root@linux4 Packages]
6、数据库重建(此处待验证) ??rpm管理器数据库的路径: /var/lib/rpm ??rpm相关的查询操作会通过此数据库运行 ??语法:rpm {–initdb|–rebuilddb} ????--initdb: 初始化数据库,当前无任何数据库可初始化创建一个新的,当前有时不执行任何操作 ????--rebuilddb:重新构建,通过读取当前系统上所有已经安装过的程序包进行重新创建
[root@linux4 lib]
/var/lib
[root@linux4 lib]
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername
[root@linux4 lib]
[root@linux4 lib]
[root@linux4 lib]
[root@linux4 lib]
[root@linux4 lib]
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername
[root@linux4 lib]
[root@linux4 rpm]
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername
[root@linux4 rpm]
[root@linux4 rpm]
[root@linux4 rpm]
Basenames Dirnames Installtid Obsoletename Providename Sha1header Triggername
Conflictname Group Name Packages Requirename Sigmd5
[root@linux4 rpm]
7、包来源合法性验证和完整性验证 ??获取并导入信任的包制作者密钥: ???对于CentOS发行版来说命令如下: ????rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ??验证: ????1、安装此组织签名的程序时会自动执行验证 ????2、手动验证:rpm -K PACKAGE_FILE
|