How 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 -e
Package 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
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The RPM (RedHatPackageManager) tool in Linux systems is a powerful tool for installing, upgrading, uninstalling and managing system software packages. It is a commonly used software package management tool in RedHatLinux systems and is also used by many other Linux distributions. The role of the RPM tool is very important. It allows system administrators and users to easily manage software packages on the system. Through RPM, users can easily install new software packages and upgrade existing software

Linux rpm is generally stored in the "/usr/local" or "/usr/bin" directory by default; the "/usr/local" directory is the "/usr" directory provided to general users, where general application software is installed, and The "/usr/bin" directory also houses many applications.

In Linux systems, RPM (RedHatPackageManager) is a common software package management tool used to install, upgrade and delete software packages. Sometimes we need to find the storage path of an installed RPM file for search or other operations. The following will introduce how to find the storage path of the RPM file in the Linux system, and provide specific code examples. First, we can use the rpm command to find the installed RPM package and its storage path. Open

1. Download 4 rpm packages 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 If you want to use Thunder to download, you must first find the corresponding rpm download path. First, open the mysql official website in the browser: In the opened interface, press the keyboard f12 to open developer tools

Rpm package management function fully understands the function of software package management: packaging the components of the compiled program into one or several package files, in order to facilitate the installation, upgrade, uninstallation, query, verification, and database of the program package maintain. Let's take a look at the analysis of RPM package management. Rpm packages have great applications in redhat and S.U.S.E. Next, we will do some detailed functional analysis on the management of rpm packages in the centos system. Using yum (rhel series), it can be automatically installed during installation. Resolve dependencies drpm package naming format: name-VERSION-release.arch.rpmVERSION: major.minor.releaseMajor

"Standard paths and code examples for RPM package storage in Linux systems" In Linux systems, RPM (RedHatPackageManager) packages are a standard format for software package management. When we use tools such as yum to install software, we are actually installing or updating RPM packages in the system. The path where RPM packages are stored in the system has certain specifications. The following will introduce the standard paths where RPM packages are stored in common Linux distributions and provide some code examples.

Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of keyvalue storage such as memcached, and can play a very good supplementary role to relational databases in some situations. Early preparation platform: centos6.5x86_64 Installation: redis-3.0.7-4.el6.art.x86_64.rpm Download the rpm package and open the address http://pkgs.org/download/redis to enter according to your own Linux platform and what you need to install Go to the redis version and download the corresponding rpm package. Here we take redis3.0.7 as an example to install: [roo

The RPM tool on Linux has always been one of the important tools for managing software packages. Whether you are a Linux system administrator or a developer, it is important to understand the basics of RPM tools. This article will provide an in-depth analysis of the LinuxRPM tool to help you better understand its principles, uses and operation methods. 1. What is the RPM tool? The full name of RPM is RedHatPackageManager. It is a tool used to manage software packages on Linux systems. its most
