centos rpm包安装
rpm
is the package format used by popular distributions like RHEL, CentPOS, Fedora and Mandriva. We generally prefer to use yum
command to install packages from internet automatically and easily. In some cases we may need to install rpm packages solely. In this tutorial we will look how to solve dependency and install rpm package.
rpm
是RHEL,CentPOS,Fedora和Mandriva等流行发行版使用的软件包格式。 通常,我们更喜欢使用yum
命令从Internet上自动轻松地安装软件包。 在某些情况下,我们可能需要仅安装rpm软件包。 在本教程中,我们将研究如何解决依赖性并安装rpm软件包。
Linux Rpm Command With Examples
Linux Rpm命令示例
We can get RPM files from different sources. In the old days RPMs generally provided with CD or floppy disk but today internet is de facto source to get RPM files. We can use following sites to search and download RPM files for different distributions, architectures.
我们可以从不同来源获得RPM文件。 在过去,RPM通常随CD或软盘一起提供,但如今,Internet实际上已成为获取RPM文件的来源。 我们可以使用以下站点来搜索和下载RPM文件以获取不同的发行版,体系结构。
http://rpm.pbone.net
http://rpm.pbone.net
In this exmaple we will download RPM file with wget.
在此示例中,我们将使用wget下载RPM文件。
$ wget ftp://mirror.switch.ch/pool/4/mirror/centos/7.4.1708/updates/x86_64/Packages/iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
Download RPM Package 下载RPM软件包
As we know packages generally requires some libraries and other packages to work accordingly. This is called package dependency. We should can list package dependencies to check whether the system met required packages.
众所周知,软件包通常需要一些库和其他软件包才能正常工作。 这称为包依赖关系。 我们应该列出软件包依赖性,以检查系统是否满足必需的软件包。
$ rpm -qpR iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
List RPM Package Dependencies 列出RPM软件包依赖性
As we can see there are some dependencies like libc, libnfnetlink etc.
如我们所见,有一些依赖项,例如libc,libnfnetlink等。
Now we assume we have installed required dependencies and ready to install our downloaded RPM package. We will provide -ivh
options and the RPM package name to the rpm
command. We should also have root privileges where we can get with sudo
like below.
现在,我们假设我们已经安装了必需的依赖项,并准备安装我们下载的RPM软件包。 我们将为rpm
命令提供-ivh
选项和RPM软件包名称。 我们还应该拥有root特权,我们可以使用sudo
获得如下特权。
$ sudo rpm -ivh iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
In some cases the system can not meet required dependencies but we should install package. May be the package can work without problem without some dependencies etc. We can install a package without dependencies with --nodeps
option like below.
在某些情况下,系统不能满足要求的依赖性,但是我们应该安装软件包。 可能是该软件包可以正常运行而没有一些依赖关系等。我们可以使用--nodeps
选项安装没有依赖关系的软件包,如下所示。
$ sudo rpm -ivh --nodeps iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
After the installation is completed we can verify that the specified package is installed correctly. We can list installed RPM packages with -qa
option and then grep the the package we recently installed. In this example we check the iptables
package.
安装完成后,我们可以验证指定的软件包是否正确安装。 我们可以使用-qa
选项列出已安装的RPM软件包,然后grep我们最近安装的软件包。 在此示例中,我们检查iptables
包。
$ rpm -qa | grep iptables
If the package is all ready installed we should upgrade to preserve the existing package configuration. We can upgrade all ready installed RPM package with the new version with -U
option like below.
如果软件包已准备就绪,我们应该升级以保留现有的软件包配置。 我们可以使用带有-U
选项的新版本升级所有现成的RPM软件包,如下所示。
$ sudo rpm -Uvh iptables-utils-1.4.21-18.2.el7_4.x86_64.rpm
翻译自: https://www.poftut.com/install-upgrade-rpm-packages-centos-rhel-fedora-mandriva/
centos rpm包安装