Linux software management .md

Software Management

1. Obtain way packages

The system releases CD or official server
http://mirrors.aliyun.com
http://mirrors.sohu.com
http://mirrors.163.com

Project official site

Third-party organization
Fedora-EPEL (recommended)
search engine:
http://pkgs.org
http://rpmfind.net
http://rpm.pbone.net

Produce their own

2. Package Manager responsibilities

The binary program, library files, configuration files, help files into one file;
when installing the software needed binary files, library files, configuration files, help files into the appropriate position;
generating a database, each file track mounted ;
when uninstalling the software will delete the corresponding file based on the generated database installation

3. The core functionality of the package manager

Authoring package
to install the software
to uninstall the software
upgrade software
for software
verification software

4. Package Management

(Unique to each package) consisting of a list of program
files list of
scripts that run when you install or uninstall

Databases (public)
package name and version
dependencies
Function
install each file generated by the file path and check information

5. Package Category

Binary format (compiled, the equipment can be used)
rpm package of download source files, compiled configuration is complete, make an rpm-
why would we do that because:?
Some features are selected at compile time, not at compile time if this feature is selected, you can not use
the rpm package version will lag behind the source package, and even many behind

Source format (needs to be compiled, also known as custom)
named: name-VERSION.tar.gz
VERSION: major.minor.release

6. Package Management Tool

Category:
front-end tools, commonly used front-end tools have the following:
yum
APT-GET
zypper (RPM front-end management tools on SUSE)
DNF (Fedora 22+ RPM front-end management tool)

Back-end tools, commonly used in back-end tools have the following:
RPM
DPT

Note: The
front-end tool is dependent on the back-end tool
front-end tool to automatically resolve dependencies exist in the back-end tools

7. Software Installation

Front-end tool installation by
installing backend tool
to compile and install

8.rpm package naming conventions

Composition package
main package: bind-9.7.1-1.el5.i586.rpm
subpacket: bind-libs-9.7.1-1.el5.i586.rpm bind- utils-9.7.1-1.el5.i586 .rpm

包名格式
name-version-release-arch.rpm
bind-major.minor.release-release.arch.rpm

Package name Format Description
major (major version number): significant improvements
minor (minor version number): sub-function of a major change
release (issue number): fixes some bug, a little adjustment function

Common Arch
x86: i386, i486, i586, i686
x86_64: x64, x86_64, AMD64
nothing to do with the platform: noarch

9.rpm package management

9.1. What is its role rpm

rpm is short for Redhat Package Manager for managing software packages.
rpm has a powerful database / var / lib / rpm.
rpm included the management of installed software, uninstall, upgrade, query, verify, rebuild the database, to verify the legitimacy of the source of the package, and so on.

9.2.rpm package installation

// syntax: RPM -ivh / the PATH / the TO / PACKAGE_FILE ...
// common options:

-i: 安装
-v: 显示详细信息
-h: 显示安装进度条

[root@localhost ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# rpm -ivh /mnt/Packages/wget-1.14-15.el7.x86_64.rpm 
警告:/mnt/Packages/wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-15.el7 ################################# [100%]
--test: 测试安装,但不真正执行安装过程

[root@localhost ~]# rpm -e wget
[root@localhost ~]# rpm -ivh --test /mnt/Packages/wget-1.14-15.el7.x86_64.rpm 
警告:/mnt/Packages/wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
[root@localhost ~]# which wget
/usr/bin/which: no wget in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
--nodeps: 忽略依赖关系

[root@localhost ~]# rpm -ivh /mnt/Packages/httpd-2.4.6-67.el7.x86_64.rpm 
警告:/mnt/Packages/httpd-2.4.6-67.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
错误:依赖检测失败:
 /etc/mime.types 被 httpd-2.4.6-67.el7.x86_64 需要
 httpd-tools = 2.4.6-67.el7 被 httpd-2.4.6-67.el7.x86_64 需要
 libapr-1.so.0()(64bit) 被 httpd-2.4.6-67.el7.x86_64 需要
 libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-67.el7.x86_64 需要
[root@localhost ~]# rpm -ivh --nodeps /mnt/Packages/httpd-2.4.6-67.el7.x86_64.rpm 
警告:/mnt/Packages/httpd-2.4.6-67.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:httpd-2.4.6-67.el7 ################################# [100%]
[root@localhost ~]# which httpd
/usr/sbin/httpd
--replacepkgs: 重新安装,替换原有安装
    --oldpackage: 降级
    --force: 强行安装,可以实现重装或降级
    --nodigest: 不检查包的完整性
    --nosignature: 不检查包的来源合法性
    --noscripts: 不执行程序包脚本片断
        %pre:安装前脚本    --nopre
        %post:安装后脚本    --nopost
        %preun:卸载前脚本    --nopreun
        %postun:卸载后脚本    --nopostun
//在软件包所在目录下可以不指定绝对路径

[root@localhost ~]# cd /mnt/Packages/
[root@localhost Packages]# rpm -ivh wget-1.14-15.el7.x86_64.rpm 
警告:wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-15.el7 ################################# [100%]

9.3.rpm package query

rpm -q PACKAGE_NAME                 //查询指定的包是否已安装

[root@localhost ~]# rpm -q wget
wget-1.14-15.el7.x86_64
rpm -qa                             //查询已经安装的所有包

[root@localhost ~]# rpm -ivh --nodeps /mnt/Packages/httpd-tools-2.4.6-67.el7.x86_64.rpm 
警告:/mnt/Packages/httpd-tools-2.4.6-67.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:httpd-tools-2.4.6-67.el7 ################################# [100%]
[root@localhost ~]# rpm -qa|grep httpd
httpd-2.4.6-67.el7.x86_64
httpd-tools-2.4.6-67.el7.x86_64
rpm -qi PACKAGE_NAME                //查询指定包的说明信息

[root@localhost ~]# rpm -qi wget
Name : wget
Version : 1.14
Release : 15.el7
Architecture: x86_64
Install Date: 2019年09月26日 星期四 14时15分44秒
Group : Applications/Internet
Size : 2055533
License : GPLv3+
Signature : RSA/SHA256, 2017年05月05日 星期五 21时44分34秒, Key ID 199e2f91fd431d51
Source RPM : wget-1.14-15.el7.src.rpm
Build Date : 2017年05月05日 星期五 20时39分40秒
Build Host : x86-019.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor : Red Hat, Inc.
URL : http://www.gnu.org/software/wget/
Summary : A utility for retrieving files using the HTTP or FTP protocols
Description :
GNU Wget is a file retrieval utility which can use either the HTTP or
FTP protocols. Wget features include the ability to work in the
background while you are logged out, recursive retrieval of
directories, file name wildcard matching, remote file timestamp
storage and comparison, use of Rest with FTP servers and Range with
HTTP servers to retrieve files over slow or unstable connections,
support for Proxy servers, and configurability.
rpm -ql PACKAGE_NAME                //查询指定软件包安装后生成的文件列表

[root@localhost ~]# rpm -ql wget
/etc/wgetrc
/usr/bin/wget
/usr/share/doc/wget-1.14
/usr/share/doc/wget-1.14/AUTHORS
/usr/share/doc/wget-1.14/COPYING
/usr/share/doc/wget-1.14/MAILING-LIST
/usr/share/doc/wget-1.14/NEWS
/usr/share/doc/wget-1.14/README
/usr/share/doc/wget-1.14/sample.wgetrc
/usr/share/info/wget.info.gz
/usr/share/locale/be/LC_MESSAGES/wget.mo
/usr/share/locale/bg/LC_MESSAGES/wget.mo
/usr/share/locale/ca/LC_MESSAGES/wget.mo
/usr/share/locale/cs/LC_MESSAGES/wget.mo
/usr/share/locale/da/LC_MESSAGES/wget.mo
/usr/share/locale/de/LC_MESSAGES/wget.mo
/usr/share/locale/el/LC_MESSAGES/wget.mo
/usr/share/locale/en_GB/LC_MESSAGES/wget.mo
/usr/share/locale/eo/LC_MESSAGES/wget.mo
/usr/share/locale/es/LC_MESSAGES/wget.mo
/usr/share/locale/et/LC_MESSAGES/wget.mo
/usr/share/locale/eu/LC_MESSAGES/wget.mo
/usr/share/locale/fi/LC_MESSAGES/wget.mo
/usr/share/locale/fr/LC_MESSAGES/wget.mo
rpm -qf /path/to/somefile           //查询指定的文件是由哪个rpm包安装生成的

[root@localhost ~]# which wget
/usr/bin/wget
[root@localhost ~]# rpm -qf /usr/bin/wget 
wget-1.14-15.el7.x86_64
[root@localhost ~]# rpm -qf /usr/bin/passwd 
passwd-0.79-4.el7.x86_64
rpm -qc PACKAGE_NAME                //查询指定包安装的配置文件
rpm -qd PACKAGE_NAME                //查询指定包安装的帮助文件

[root@localhost ~]# rpm -qc wget
/etc/wgetrc
[root@localhost ~]# rpm -qd wget
/usr/share/doc/wget-1.14/AUTHORS
/usr/share/doc/wget-1.14/COPYING
/usr/share/doc/wget-1.14/MAILING-LIST
/usr/share/doc/wget-1.14/NEWS
/usr/share/doc/wget-1.14/README
/usr/share/doc/wget-1.14/sample.wgetrc
/usr/share/info/wget.info.gz
/usr/share/man/man1/wget.1.gz
rpm -q --scripts PACKAGE_NAME       //查询指定包中包含的脚本

[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 || :
rpm -q --whatprovides CAPABILITY    //查询指定的CAPABILITY(能力)由哪个包所提供
    如:rpm -q --whatprovides /bin/cat

[root@localhost ~]# rpm -q --whatprovides /bin/cat
coreutils-8.22-18.el7.x86_64
[root@localhost ~]# rpm -q --whatprovides /usr/bin/passwd 
passwd-0.79-4.el7.x86_64
rpm -q --whatrequires CAPABILITY    //查询指定的CAPABILITY被哪个包所依赖

[root@localhost ~]# rpm -q --whatrequires httpd-tools
httpd-2.4.6-67.el7.x86_64
rpm -q --changelog COMMAND          //查询COMMAND的制作日志

[root@localhost ~]# rpm -q --changelog wget
* 五 5月 05 2017 Tomas Hozza <[email protected]> - 1.14-15
- Added TLSv1_1 and TLSv1_2 as secure-protocol values to help (#1439811)
- Fixed synchronization in randomly failing unit test Test-proxied-https-auth (#1448440)

* 三 4月 12 2017 Tomas Hozza <[email protected]> - 1.14-14
- TLS v1.1 and v1.2 can now be specified with --secure-protocol option (#1439811)

* 一 6月 20 2016 Tomas Hozza <[email protected]> - 1.14-13
- Fix CVE-2016-4971 (#1345778)
- Added support for non-ASCII URLs (Related: CVE-2016-4971)

* 一 3月 21 2016 Tomas Hozza <[email protected]> - 1.14-12
- Fix wget to include Host header on CONNECT as required by HTTP 1.1 (#1203384)
- Run internal test suite during build (#1295846)
- Fix -nv being documented as synonym for two options (#1147572)

* 五 10月 24 2014 Tomas Hozza <[email protected]> - 1.14-11
- Fix CVE-2014-4877 wget: FTP symlink arbitrary filesystem access (#1156136)

* 五 1月 24 2014 Daniel Mach <[email protected]> - 1.14-10
rpm -q --scripts PACKAGE_NAME       //查询指定软件包包含的所有脚本文件
rpm -qR PACKAGE_NAME                //查询指定的软件包所依赖的CAPABILITY
rpm -q --provides PACKAGE_NAME      //列出指定软件包所提供的CAPABILITY
rpm -qpi /PATH/TO/PACKAGE_FILE      //查询指定未安装包的说明信息

[root@localhost ~]# rpm -e wget
[root@localhost ~]# rpm -qi wget
未安装软件包 wget 
[root@localhost ~]# rpm -qpi /mnt/Packages/wget-1.14-15.el7.x86_64.rpm 
警告:/mnt/Packages/wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
Name : wget
Version : 1.14
Release : 15.el7
Architecture: x86_64
Install Date: (not installed)
Group : Applications/Internet
Size : 2055533
License : GPLv3+
Signature : RSA/SHA256, 2017年05月05日 星期五 21时44分34秒, Key ID 199e2f91fd431d51
Source RPM : wget-1.14-15.el7.src.rpm
Build Date : 2017年05月05日 星期五 20时39分40秒
Build Host : x86-019.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor : Red Hat, Inc.
URL : http://www.gnu.org/software/wget/
Summary : A utility for retrieving files using the HTTP or FTP protocols
Description :
GNU Wget is a file retrieval utility which can use either the HTTP or
FTP protocols. Wget features include the ability to work in the
background while you are logged out, recursive retrieval of
directories, file name wildcard matching, remote file timestamp
storage and comparison, use of Rest with FTP servers and Range with
HTTP servers to retrieve files over slow or unstable connections,
support for Proxy servers, and configurability.
rpm -qpl /PATH/TO/PACKAGE_FILE      //查询未安装的软件包会产生哪些文件

[root@localhost ~]# rpm -qpl /mnt/Packages/wget-1.14-15.el7.x86_64.rpm 
警告:/mnt/Packages/wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
/etc/wgetrc
/usr/bin/wget
/usr/share/doc/wget-1.14
/usr/share/doc/wget-1.14/AUTHORS
/usr/share/doc/wget-1.14/COPYING
/usr/share/doc/wget-1.14/MAILING-LIST
/usr/share/doc/wget-1.14/NEWS
/usr/share/doc/wget-1.14/README
/usr/share/doc/wget-1.14/sample.wgetrc
/usr/share/info/wget.info.gz
/usr/share/locale/be/LC_MESSAGES/wget.mo
/usr/share/locale/bg/LC_MESSAGES/wget.mo
/usr/share/locale/ca/LC_MESSAGES/wget.mo
/usr/share/locale/cs/LC_MESSAGES/wget.mo
/usr/share/locale/da/LC_MESSAGES/wget.mo
/usr/share/locale/de/LC_MESSAGES/wget.mo
/usr/share/locale/el/LC_MESSAGES/wget.mo
/usr/share/locale/en_GB/LC_MESSAGES/wget.mo
/usr/share/locale/eo/LC_MESSAGES/wget.mo
/usr/share/locale/es/LC_MESSAGES/wget.mo
/usr/share/locale/et/LC_MESSAGES/wget.mo
/usr/share/locale/eu/LC_MESSAGES/wget.mo
/usr/share/locale/fi/LC_MESSAGES/wget.mo
/usr/share/locale/fr/LC_MESSAGES/wget.mo
/usr/share/locale/ga/LC_MESSAGES/wget.mo
/usr/share/locale/gl/LC_MESSAGES/wget.mo
/usr/share/locale/he/LC_MESSAGES/wget.mo
/usr/share/locale/hr/LC_MESSAGES/wget.mo
/usr/share/locale/hu/LC_MESSAGES/wget.mo
/usr/share/locale/id/LC_MESSAGES/wget.mo
/usr/share/locale/it/LC_MESSAGES/wget.mo
/usr/share/locale/ja/LC_MESSAGES/wget.mo
/usr/share/locale/lt/LC_MESSAGES/wget.mo
/usr/share/locale/nb/LC_MESSAGES/wget.mo
/usr/share/locale/nl/LC_MESSAGES/wget.mo
/usr/share/locale/pl/LC_MESSAGES/wget.mo
/usr/share/locale/pt/LC_MESSAGES/wget.mo
/usr/share/locale/pt_BR/LC_MESSAGES/wget.mo
/usr/share/locale/ro/LC_MESSAGES/wget.mo
/usr/share/locale/ru/LC_MESSAGES/wget.mo
/usr/share/locale/sk/LC_MESSAGES/wget.mo
/usr/share/locale/sl/LC_MESSAGES/wget.mo
/usr/share/locale/sr/LC_MESSAGES/wget.mo
/usr/share/locale/sv/LC_MESSAGES/wget.mo
/usr/share/locale/tr/LC_MESSAGES/wget.mo
/usr/share/locale/uk/LC_MESSAGES/wget.mo
/usr/share/locale/vi/LC_MESSAGES/wget.mo
/usr/share/locale/zh_CN/LC_MESSAGES/wget.mo
/usr/share/locale/zh_TW/LC_MESSAGES/wget.mo
/usr/share/man/man1/wget.1.gz

9.4.rpm upgrade package

rpm -Uvh /PATH/TO/NEW_PACKAGE_FILE  //如果装有老版本的,则升级;否则,则安装

[root@localhost ~]# rpm -ivh /mnt/Packages/wget-1.14-15.el7.x86_64.rpm 
警告:/mnt/Packages/wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-15.el7 ################################# [100%]
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
--2019-09-26 14:56:20-- http://mirror.centos.org/centos/7/os/x86_64/Packages/wget-1.14-18.el7_6.1.x86_64.rpm
正在解析主机 mirror.centos.org (mirror.centos.org)... 160.116.15.18, 2604:1380:3000:2800::1
正在连接 mirror.centos.org (mirror.centos.org)|160.116.15.18|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:560272 (547K) [application/x-rpm]
正在保存至: “wget-1.14-18.el7_6.1.x86_64.rpm”

100%[=========================================================================>] 560,272 121KB/s 用时 4.5s   

2019-09-26 14:56:26 (121 KB/s) - 已保存 “wget-1.14-18.el7_6.1.x86_64.rpm” [560272/560272])

[root@localhost ~]# ls
a abc anaconda-ks.cfg dh dh.tar.bz2 test wget-1.14-18.el7_6.1.x86_64.rpm
[root@localhost ~]# rpm -Uvh wget-1.14-18.el7_6.1.x86_64.rpm 
警告:wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-18.el7_6.1 ################################# [ 50%]
正在清理/删除...
   2:wget-1.14-15.el7 ################################# [100%]
[root@localhost ~]# rpm -qa|grep wget
wget-1.14-18.el7_6.1.x86_64
[root@localhost ~]# rpm -e wget
[root@localhost ~]# rpm -qa|grep wget
[root@localhost ~]# ld
ld:没有输入文件
[root@localhost ~]# ls
a abc anaconda-ks.cfg dh dh.tar.bz2 test wget-1.14-18.el7_6.1.x86_64.rpm
[root@localhost ~]# rpm -Uvh wget-1.14-18.el7_6.1.x86_64.rpm 
警告:wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-18.el7_6.1 ################################# [100%]
[root@localhost ~]# rpm -qa|grep wget
wget-1.14-18.el7_6.1.x86_64
rpm -Fvh /PATH/TO/NEW_PACKAGE_FILE  //如果装有老版本的,则升级;否则,退出

[root@localhost ~]# rpm -e wget
[root@localhost ~]# rpm -qa|grep wget
[root@localhost ~]# ls
a abc anaconda-ks.cfg dh dh.tar.bz2 test wget-1.14-18.el7_6.1.x86_64.rpm
[root@localhost ~]# rpm -Fvh wget-1.14-18.el7_6.1.x86_64.rpm 
警告:wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
[root@localhost ~]# rpm -qa|grep wget
[root@localhost ~]# rpm -ivh /mnt/Packages/wget-1.14-15.el7.x86_64.rpm 
警告:/mnt/Packages/wget-1.14-15.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-15.el7 ################################# [100%]
[root@localhost ~]# rpm -qa|grep wget
wget-1.14-15.el7.x86_64
[root@localhost ~]# ls
a abc anaconda-ks.cfg dh dh.tar.bz2 test wget-1.14-18.el7_6.1.x86_64.rpm
[root@localhost ~]# rpm -Fvh wget-1.14-18.el7_6.1.x86_64.rpm 
警告:wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:wget-1.14-18.el7_6.1 ################################# [ 50%]
正在清理/删除...
   2:wget-1.14-15.el7 ################################# [100%]
[root@localhost ~]# rpm -qa|grep wget
wget-1.14-18.el7_6.1.x86_64

Upgrade considerations:

Do not do the upgrade of the core operation
Linux support multi-core versions co-exist, therefore, to install a new version of the kernel directly
if the original installation package configuration file has been modified, upgrade, the new version provides the same configuration file does not directly cover after the old version of the configuration file, the new version of the file is renamed (FILENAME.rpmnew) reserved

9.5.rpm Pack Uninstall

//语法:rpm -e PACKAGE_NAME
//先查询, 然后卸载 

[root@localhost ~]# rpm -qa|grep wget
wget-1.14-18.el7_6.1.x86_64
[root@localhost ~]# rpm -e wget
[root@localhost ~]# rpm -qa|grep wget

Note : If you want to uninstall other packages depend on the package, this package is dependent not be removed, unless forced to uninstall other programs that rely on the force uninstall this package will not work

9.6.rpm bag check

// 如果执行以下命令无内容输出说明此包未被修改过

[root@localhost ~]# rpm -ivh /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm 
警告:/mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
准备中... ################################# [100%]
正在升级/安装...
   1:vsftpd-3.0.2-22.el7 ################################# [100%]
[root@localhost ~]# ls /etc/vsftpd/
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@localhost ~]# rpm -V vsftpd
[root@localhost ~]# echo 'haha' >> /etc/vsftpd/vsftpd.conf 
[root@localhost ~]# rpm -V vsftpd
S.5....T. c /etc/vsftpd/vsftpd.conf

9.7.rpm rebuild the database

Database information in / var / lib / rpm directory

rpm --rebuilddb     //重建数据库,一定会重新建立
rpm --initdb        //初始化数据库,没有才建立,有就不用建立

[root@localhost ~]# ls /var/lib/rpm
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername
[root@localhost ~]# rpm --rebuliddb
rpm: --rebuliddb: 未知的选项
[root@localhost ~]# rpm --rebuilddb
[root@localhost ~]# ls /var/lib/rpm
Basenames Dirnames Installtid Obsoletename Providename Sha1header Triggername
Conflictname Group Name Packages Requirename Sigmd5
[root@localhost ~]# rm -rf /var/lib/rpm/*
[root@localhost ~]# ls /var/lib/rpm
[root@localhost ~]# rpm --initdb
[root@localhost ~]# ls /var/lib/rpm
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername

9.8. Check the source of legitimacy and integrity of the package

加密类型:
    对称加密    //加密解密使用同一个密钥
    公钥加密    //一对密钥,公钥和私钥。公钥隐含于私钥中,可以提取出来并公布出去
    单向加密    //只能加密不能解密
    
/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release     //红帽官方公钥

rpm -K PACKAGE_FILE     //检查指定包有无密钥信息
    dsa,gpg            //验证来源合法性,也即验证签名。可以使用--nosignatrue略过此项
    sha1,md5           //验证软件包完整性。可以使用--nodigest略过此项
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release    //导入密钥文件
    CentOS 7发行版光盘提供的密钥文件    //RPM-GPG-KEY-CentOS-7

Guess you like

Origin www.cnblogs.com/liping0826/p/11592111.html