Linux software installation method of rpm package installation

RPM Package Manager (Red Hat Package Manager)

In the early days, if you want to install software in the Linux system, you can only install it in a source package. Every time you want to install a program, you need to find the source code and then compile it into a binary file. This process takes a lot of time, and what's more annoying is that When installing, upgrading, and uninstalling service programs, the dependencies of other programs and libraries are often considered, and the operation difficulty and intensity are very high. In order to solve these problems, the package manager came into being. It packaged each set of files of the compiled application into one or several package files, so as to more conveniently realize the installation, upgrade, uninstallation and query of the package. Management operations.

RPM is named "RedHat Package Manager", or RPM for short. This mechanism was first developed by the company Red Hat. The biggest feature of RPM is that the software that needs to be installed has been compiled and packaged into an installation package of the RPM mechanism, and the dependent software required for the software installation is recorded through the default database inside. When installing on your Linux host, RPM will first query whether the dependency property software of the Linux host is satisfied according to the data in the software, if it is satisfied, it will be installed, if it is not satisfied, it will not be installed.

RPM package format

The standard format RPM package consists of package name, version information, release version number, operating platform, and extension.
httpd-2.4.6-17.el7.x86_64.rpm (httpd: software name; -2.4.6: version; -17.el7: release version number, where el7 represents RHEL7; x86_64: operating platform) in
other formats PRM package
*.src.rpm: This kind of package is a source program package and cannot be installed and run directly. It must be compiled first, such as httpd-2.4.6-17.el7.src.rpm
*.noarch.rpm: it can be in different Use
*.athlon.rpm on cpu : This package emphasizes the better performance of AMD cpu on AMD systems

RPM default installation path

After the rpm software is installed, the relevant information of the software will be written into the database file under the /var/lob/rpm/ directory. The /var/lob/rpm/ directory is required for rpm software upgrades, queries, digital signatures, etc.

/etc                  配置文件的目录
/usr/bin              可执行文件
/usr/lib              一些程序使用的动态函式库
/usr/share/doc        软件的使用手册与说明文件
/usr/share/man        一些 man page 文件

RPM package management commands

Command syntax : rpm [option] [rpm package name]
related parameters

-q			查询(软件包名或文件名)
-i或--install	        安装(软件包)
-U或--upgrade	        升级(软件包)
-e或--erase		卸载(软件包),注意后面软件名(即通过-q查询并显示出来的名字)而不是安装包名。
-v或--verify	        可视化,也就是提供详细的信息输出
-h或--hash		显示进度
-a			所有(软件包)
-l		        显示软件包的文件列表
-d			显示被标注为文档的文件列表
-c			显示被标注为配置文件的文件列表,常用于查询软件包的配置文件列表
-f			文件所属与哪个(软件包)
-t			测试安装(软件包)
--force			表示强制安装,即使覆盖属于其他包的文件也要安装
--nodeps		表示忽略软件包之间的依赖关系,强制安装或卸载,有可能因为缺少依赖包而无法正常使用,不建议使用此方法。

Common command combinations

rpm -ivh httpd-2.4.6-17.el7.x86_64.rpm
installs the httpd software package, visualizes it, and displays the installation progress. -ivh is the classic option combination for installing the rpm software package.

[root@hollowman ~]#cd /media/cdrom/Packages
[root@hollowman Packages]# rpm -ivh httpd-2.4.6-17.el7.x86_64.rpm 
warning: httpd-2.4.6-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
	httpd-tools = 2.4.6-17.el7 is needed by httpd-2.4.6-17.el7.x86_64

From the information prompt, we can find that httpd needs to install the dependency package httpd-tools first

[root@hollowman Packages]# rpm -ivh httpd-tools-2.4.6-17.el7.x86_64.rpm
warning: httpd-tools-2.4.6-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:httpd-tools-2.4.6-17.el7         ################################# [100%]

Install the httpd package again, this time it was successfully installed.

[root@hollowman Packages]# rpm -ivh httpd-2.4.6-17.el7.x86_64.rpm
warning: httpd-2.4.6-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:httpd-2.4.6-17.el7               ################################# [100%]

The rpm -qa
-qa option means to query all packages (the -a option alone is not complete, it needs to be combined with the -q option, query + all = query all packages)
rpm -qa|grep httpd
through the pipe character and the grep command Realization of querying all packages containing httpd

[root@hollowman ~]# rpm -qa|grep httpd
httpd-tools-2.4.6-17.el7.x86_64
httpd-2.4.6-17.el7.x86_64

It can be seen that the two packages containing httpd that were installed just now are all displayed.
rpm -qi httpd
queries the information of the installed httpd software (see the literal meaning of the parameter, query + installation = query the installed software package), here you only need to enter the abbreviation of the package name, which is the httpd- queried above 2.4.6-17. The abbreviation of el7.x86_64 software, of course, you can also enter the full name of the software package.

[root@hollowman ~]# rpm -qi httpd
Name        : httpd
Version     : 2.4.6
Release     : 17.el7
Architecture: x86_64
Install Date: Thu 10 Dec 2020 10:36:43 PM CST
Group       : System Environment/Daemons
Size        : 3863865
License     : ASL 2.0
Signature   : RSA/SHA256, Wed 02 Apr 2014 01:54:28 AM CST, Key ID 199e2f91fd431d51
Source RPM  : httpd-2.4.6-17.el7.src.rpm
Build Date  : Thu 20 Mar 2014 07:17:12 PM CST
Build Host  : x86-024.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : http://httpd.apache.org/
Summary     : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.

rpm -e httpd
uninstalls the httpd package combination, generally according to the dependency relationship, and the installation order is opposite, because the installation order is httpd-tools, httpd, all uninstallation is best to reverse uninstall. In the same way, you only need to enter the package abbreviation for the following package name.
rpm -e httpd-tools
uninstall httpd-tools software package
rpm -qf file name
query which software package the file name belongs to

Guess you like

Origin blog.csdn.net/ymz641/article/details/111472917