search
HomeSystem TutorialLINUXHow to install, update and uninstall RPM software packages under Linux

Under the Linux operating system, almost all software is installed, uninstalled and managed through RPM. The full name of RPM is Redhat Package Manager, which is a software proposed by Redhat Company for managing software packages under Linux. When installing Linux, except for a few core modules, almost all other modules are installed through RPM. RPM has five operating modes: installation, uninstallation, upgrade, query and verification.

RPM installation operation

Order:
rpm -i package file name to be installed
Examples are as follows:

rpm -i example.rpm 安装 example.rpm 包;
rpm -iv example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息;
rpm -ivh example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息及安装进度;

RPM Query Operation

Order:
rpm -q …
Additional query command:

a Query all installed packages The following two additional commands are used to query installation package information;
i displays the installation package information;
l Display the directories to which all files in the installation package are installed;
s displays the status of all files in the installation version and the directories where they are installed; the following two additional commands are used to specify whether the installation package or the installed file needs to be queried;
p queries the installation package information;
f queries the information of a certain installed file;

Examples are as follows:

rpm -qa | grep tomcat4 查看 tomcat4 是否被安装;
rpm -qip example.rpm 查看 example.rpm 安装包的信息;
rpm -qif /bin/df 查看/bin/df 文件所在安装包的信息;
rpm -qlf /bin/df 查看/bin/df 文件所在安装包中的各个文件分别被安装到哪个目录下;

RPM uninstall operation

Order:
rpm -e Installation package that needs to be uninstalled
Before uninstalling, you usually need to use the rpm -q... command to find out the name of the installation package that needs to be uninstalled.
Examples are as follows:
rpm -e tomcat4 Uninstall tomcat4 package

RPM upgrade operation

Order:
rpm -U Packages that need to be upgraded

Examples are as follows:
rpm -Uvh example.rpm Upgrade example.rpm package
RPM Verification Operation
Order:
rpm -V Packages that need to be verified

Examples are as follows:
rpm -Vf /etc/tomcat4/tomcat4.conf
The output information is similar to the following:
S.5....T c /etc/tomcat4/tomcat4.conf
Among them, S indicates that the file size has been modified, and T indicates that the file date has been modified. Due to space limitations, for more verification information, please refer to the rpm help file: man rpm

Other additional commands for RPM

--force forced operations such as forced installation, deletion, etc.;
--requires displays the dependencies of this package;
--nodeps Ignore dependencies and continue;

The rpm command is a management tool for RPM software packages. rpm was originally a program used by the Red Hat Linux distribution to manage various Linux packages. It is very popular because it follows GPL rules and is powerful and convenient. Gradually adopted by other distributions. The emergence of RPM package management method makes Linux easy to install and upgrade, which indirectly improves the applicability of Linux.

grammar

rpm(选项)(参数)

Options

-a:查询所有套件;
-b+或-t +:设置包装套件的完成阶段,并指定套件档的文件名称;
-c:只列出组态配置文件,本参数需配合"-l"参数使用;
-d:只列出文本文件,本参数需配合"-l"参数使用;
-e或--erase:删除指定的套件;
-f+:查询拥有指定文件的套件;
-h或--hash:套件安装时列出标记;
-i:显示套件的相关信息;
-i或--<span class="wp_keywordlink"><a href="https://www.php.cn/link/5ca41a86596a5ed567d15af0be224952" rel="nofollow" target="_blank">install</a></span>:安装指定的套件档;
-l:显示套件的文件列表;
-p+:查询指定的RPM套件档;
-q:使用询问模式,当遇到任何问题时,rpm指令会先询问用户;
-R:显示套件的关联性信息;
-s:显示文件状态,本参数需配合"-l"参数使用;
-U或--upgrade:升级指定的套件档;
-v:显示指令执行过程;
-vv:详细显示指令执行过程,便于排错。

parameter

Software package: Specify the rpm package to be manipulated.

Example

How to install rpm package

Installation of rpm software packages can be done using the program rpm. Execute the following command:

rpm -ivh your-package.rpm

Where your-package.rpm is the file name of the rpm package you want to install, usually placed in the current directory.

The following warnings or prompts may appear during the installation process:

... conflict with ...

It may be that there are some files in the package to be installed that may overwrite existing files. By default, such a situation cannot be installed correctly. You can use rpm --force -i to force the installation. Can

... is needed by ...
... is not installed ...

If you have not installed some software required by this package, you can use rpm --nodeps -i to ignore this information, which means rpm -i --force --nodeps is OK. Ignoring all dependencies and file issues, any package can be installed, but such forced installation of software packages cannot guarantee full functionality.

How to install the .src.rpm package

Some software packages end with .src.rpm. This type of software package is an rpm package containing source code and needs to be compiled during installation. There are two installation methods for this type of software package:

method one:

rpm -i your-package.src.rpm
<span class="wp_keywordlink"><a href="https://www.php.cn/link/01632f7b7a127233fa1188bd6c2e42e1" rel="nofollow" target="_blank">cd</a></span> /usr/src/redhat/SPECS
<span class="wp_keywordlink"><a href="https://www.php.cn/link/a2c770e3cc20139f429ebfe6e8cdea0b" rel="nofollow" target="_blank">rpmbuild</a></span> -bp your-package.specs<span style="color: #808080"> #一个和你的软件包同名的specs文件</span>
cd /usr/src/redhat/BUILD/your-package/<span style="color: #808080">#一个和你的软件包同名的目录</span>
./configure <span style="color: #808080">#这一步和编译普通的源码软件一样,可以加上参数</span>
<span class="wp_keywordlink"><a href="https://www.php.cn/link/03dadd644cb5856e1bb2c75dda01a4f0" rel="nofollow" target="_blank">make</a></span>
make install

Method Two:

rpm -i you-package.src.rpm
cd /usr/src/redhat/SPECS

The first two steps are the same as method 1

rpmbuild -bb your-package.specs #一个和你的软件包同名的specs文件

At this time, there is a new rpm package in /usr/src/redhat/RPM/i386/ (depending on the specific package, it may be i686, noarch, etc.). , this is a compiled binary file.

Execute rpm -i new-package.rpm to complete the installation.

How to uninstall rpm package

Use the command rpm -ePackage name. The package name can contain version number and other information, but it cannot have the suffix .rpm. For example, to uninstall the software package proftpd-1.2.8-1, you can use the following format:

rpm -e proftpd-1.2.8-1
rpm -e proftpd-1.2.8
rpm -e proftpd-
rpm -e proftpd

cannot be in the following format:

rpm -e proftpd-1.2.8-1.i386.rpm
rpm -e proftpd-1.2.8-1.i386
rpm -e proftpd-1.2
rpm -e proftpd-1

Sometimes some errors or warnings may appear:

... is needed by ...

This means that this software is needed by other software and cannot be uninstalled casually. You can use rpm -e --nodeps to force uninstall

How to get the files in the rpm package without installing it

Using toolsrpm2cpio and cpio

rpm2cpio xxx.rpm | cpio -<span class="wp_keywordlink"><a href="https://www.php.cn/link/a8621fdfb85b64f3214f86af1e1504a2" rel="nofollow" target="_blank">vi</a></span>
rpm2cpio xxx.rpm | cpio -idmv
rpm2cpio xxx.rpm | cpio --extract --make-directories

参数i和extract相同,表示提取文件。v表示指示执行进程,d和make-directory相同,表示根据包中文件原来的路径建立目录,m表示保持文件的更新时间。

如何查看与rpm包相关的文件和其他信息

下面所有的例子都假设使用软件包mysql-3.23.54a-11

1、我的系统中安装了那些rpm软件包。

rpm -qa 讲列出所有安装过的包

如果要查找所有安装过的包含某个字符串sql的软件包

rpm -qa | <span class="wp_keywordlink"><a href="https://www.php.cn/link/c467978aaae44a0e8054e174bc0da4bb" rel="nofollow" target="_blank">grep</a></span> sql

2、如何获得某个软件包的文件全名。

rpm -q mysql

可以获得系统中安装的mysql软件包全名,从中可以获得当前软件包的版本等信息。这个例子中可以得到信息mysql-3.23.54a-11

3、一个rpm包中的文件安装到那里去了?

rpm -ql 包名

注意这里的是不包括.rpm后缀的软件包的名称,也就是说只能用mysql或者mysql-3.23.54a-11而不是mysql-3.23.54a-11.rpm。如果只是想知道可执行程序放到那里去了,也可以用which,比如:

which mysql

4、一个rpm包中包含那些文件。

  • 一个没有安装过的软件包,使用rpm -qlp ****.rpm
  • 一个已经安装过的软件包,还可以使用rpm -ql ****.rpm

5、如何获取关于一个软件包的版本,用途等相关信息?

  • 一个没有安装过的软件包,使用rpm -qip ****.rpm
  • 一个已经安装过的软件包,还可以使用rpm -qi ****.rpm

6、某个程序是哪个软件包安装的,或者哪个软件包包含这个程序。

rpm -qf `which 程序名`<span style="color: #808080">#返回软件包的全名</span>
rpm -qif `which 程序名` <span style="color: #808080">#返回软件包的有关信息</span>
rpm -qlf `which 程序名` <span style="color: #808080">#返回软件包的文件列表</span>

注意,这里不是引号,而是`,就是键盘左上角的那个键。也可以使用rpm -qilf,同时输出软件包信息和文件列表。

7、某个文件是哪个软件包安装的,或者哪个软件包包含这个文件。

注意,前一个问题中的方法,只适用与可执行的程序,而下面的方法,不仅可以用于可执行程序,也可以用于普通的任何文件。前提是知道这个文件名。首先获得这个程序的完整路径,可以用whereis或者which,然后使用rpm -qf例如:

<span style="color: #ff0000">whereis <span class="wp_keywordlink"><a href="https://www.php.cn/link/96fca94df72984fc97ee5095410d4dec" rel="nofollow" target="_blank">ftptop</a></span></span>
ftptop: /usr/bin/ftptop /usr/share/<span class="wp_keywordlink"><a href="https://www.php.cn/link/432fd02f951f393df1591310e6811118" rel="nofollow" target="_blank">man</a></span>/man1/ftptop.1.gz

<span style="color: #ff0000">rpm -qf /usr/bin/ftptop</span>
proftpd-1.2.8-1

<span style="color: #ff0000">rpm -qf /usr/share/doc/proftpd-1.2.8/rfc/rfc0959.txt</span>
proftpd-1.2.8-1

The above is the detailed content of How to install, update and uninstall RPM software packages under Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:脚本之家. If there is any infringement, please contact admin@php.cn delete
如何查找Linux系统中RPM文件的存储路径?如何查找Linux系统中RPM文件的存储路径?Mar 14, 2024 pm 04:42 PM

在Linux系统中,RPM(RedHatPackageManager)是一种常见的软件包管理工具,用于安装、升级和删除软件包。有时候我们需要找到某个已安装的RPM文件的存储路径,以便进行查找或者其他操作。下面将介绍在Linux系统中如何查找RPM文件的存储路径,同时提供具体的代码示例。首先,我们可以使用rpm命令来查找已安装的RPM包及其存储路径。打开

linux rpm 存放在哪linux rpm 存放在哪Mar 28, 2023 am 11:22 AM

linux rpm一般默认存放在“/usr/local”或者“/usr/bin”目录下;“/usr/local”目录是提供给一般用户的“/usr”目录,在这里安装一般的应用软件,而“/usr/bin”目录也存放着许多应用程序。

深入探讨Linux RPM工具的作用和原理深入探讨Linux RPM工具的作用和原理Feb 23, 2024 pm 03:00 PM

Linux系统中的RPM(RedHatPackageManager)工具是一种用于安装、升级、卸载和管理系统软件包的强大工具。它是RedHatLinux系统中常用的软件包管理工具,也被许多其他Linux发行版采用。RPM工具的作用非常重要,它使得系统管理员和用户能够方便地管理系统上的软件包。通过RPM,用户可以很容易地安装新的软件包,升级现有的软件

centos7使用rpm安装mysql5.7的方法centos7使用rpm安装mysql5.7的方法May 27, 2023 am 08:05 AM

1.下载4个rpm包mysql-community-client-5.7.26-1.el7.x86_64.rpmmysql-community-common-5.7.26-1.el7.x86_64.rpmmysql-community-libs-5.7.26-1.el7.x86_64.rpmmysql-community-server-5.7.26-1.el7.x86_64.rpm想要用迅雷进行下载得先找到对应的rpm下载路径首先浏览器打开mysql官网:在打开的界面,按键盘f12打开开发者工具

如何进行rpm程序包管理功能解析如何进行rpm程序包管理功能解析May 24, 2023 am 09:01 AM

Rpm包管理功能全解软件包管理的功能:将编译好的程序的各组成文件打包成一个或几个程序包文件,为了方便的实现程序包的安装、升级、卸载、查询、校验、数据库维护。下面我们来看看RPM包管理的解析Rpm包在redhat和S.U.S.E中有很大的应用我们接下来就以centos系统中rpm包的管理做一些详细的功能解析使用yum(rhel系列)安装时可以自动解决依赖关系drpm包命名格式:name-VERSION-release.arch.rpmVERSION:major.minor.releaseMajor

Linux系统中RPM包存放的标准路径是什么?Linux系统中RPM包存放的标准路径是什么?Mar 14, 2024 am 11:18 AM

《Linux系统中RPM包存放的标准路径及代码示例》在Linux系统中,RPM(RedHatPackageManager)包是一种用于软件包管理的标准格式。当我们使用yum等工具安装软件的时候,实际上是在系统中安装或更新RPM包。RPM包在系统中存放的路径是有一定规范的,下面将介绍一下在常见的Linux发行版中RPM包存放的标准路径,并提供一些代码示例

CentOS中怎么使用RPM包安装redisCentOS中怎么使用RPM包安装redisMay 26, 2023 am 11:47 AM

Redis是一个高性能的key-value数据库。redis的出现,很大程度补偿了memcached这类keyvalue存储的不足,在部分场合可以对关系数据库起到很好的补充作用。前期准备平台:centos6.5x86_64安装:redis-3.0.7-4.el6.art.x86_64.rpm下载rpm包打开地址http://pkgs.org/download/redis进入根据自己的linux平台以及需要安装的redis版本进去下载对应的rpm包,这里我们以redis3.0.7为例安装:[roo

Linux RPM工具解析:你需要了解的基础知识Linux RPM工具解析:你需要了解的基础知识Feb 22, 2024 pm 06:36 PM

Linux上的RPM工具一直以来都是管理软件包的重要工具之一。无论你是一名Linux系统管理员,还是一名开发者,了解RPM工具的基础知识都是非常重要的。本文将深入解析LinuxRPM工具,帮助你更好地理解其原理、用途和操作方法。一、什么是RPM工具RPM全称为RedHatPackageManager,是一种用于在Linux系统上管理软件包的工具。它最

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool