Linux RPM command parameters use Daquan (Classic)

Time:2021-10-25

Rpm is the RedHat package manager (RedHat package management tool), which is similar to the “add / Remove Program” in windows

RPM execution installation package

Binary package and source package. Binary packages can be installed directly on the computer, and source code packages will be compiled and installed automatically by rpm. Source code packages often use src.rpm as a suffix.

Common command combinations:

– IVH: display installation progress — install — verbose — hash
– uvh: upgrade package — update;
– QPL: list the file information in RPM software package [query package list];
– QPI: list description information of RPM software package [query package install package (s)];
– QF: find which RPM package the specified file belongs to [query file];
– VA: check all RPM software packages and find the missing file [View lost];
– E: delete package

RPM - Q Samba // query whether the program is installed
RPM - IVH / media / CDROM / RedHat / RPMs / Samba -.. -. E.i.rpm // install according to the path and display the progress
RPM - IVH -- relocate / = / opt / GAIM GAIM -.. -. FC. I.rpm // specify the installation directory
RPM - IVH -- Test GAIM -.. -. FC. I.rpm // used to check dependencies; Not a real installation;
RPM - uvh -- oldpackage GAIM -.. -. FC. I.rpm // the new version is downgraded to the old version
RPM - QA | grep httpd [search whether the specified RPM package is installed] - all search * httpd*
RPM - QL httpd [search RPM package] - list all file installation directories
RPM - QPI Linux -. -. I.rpm [View RPM package] - query -- package -- install package information
RPM - QPF Linux -. -. I.rpm [View RPM package] - file
RPM - QPR file.rpm [View package] dependency
Rpmcpio file.rpm | CPIO - div [extract file]
RPM - IVH file.rpm [install new RPM] - install -- verbose -- hash
rpm -ivh
RPM - uvh file.rpm [upgrade an RPM] - upgrade
RPM - e file.rpm [delete an RPM package] - erase

Common parameters:

Install/Upgrade/Erase options:

-i, –install                     install package(s)
-v, –verbose                     provide more detailed output
-h, –hash                        print hash marks as package installs (good with -v)
-e, –erase                       erase (uninstall) package
-U, –upgrade=<packagefile>+      upgrade package(s)
--replacepkge                     Force the installation of the software package whether it has been installed or not
–test                             Installation test, not actual installation
–nodeps                           Ignore package dependencies and force installation
–force                            Ignore conflicts between packages and files
Query options (with -q or –query):
-a, –all                         query/verify all packages
-p, –package                     query/verify a package file
-l, –list                        list files in package
-d, –docfiles                    list all documentation files
-f, –file                        query/verify package(s) owning file

RPM source code packaging installation

. src.rpm. These files are packaged by the source code of the software. To install this kind of RPM package, you must use the command:

rpm –recompile vim-4.6-4.src.rpm    # This command will unpack the source code, compile and install it. If the user uses the command:
RPM — rebuild vim-4.6-4.src.rpm after installation, the compiled executable file will be repackaged into the RPM package of i386.rpm.

I don’t like to write complicated things. If it’s troublesome, but as a reference, I also transferred a person’s’ writing, which is really comprehensive`

Author: North South North South
From: linuxsir.org
Abstract: RPM is the abbreviation of red hat package manager, which originally means red hat package management; This paper introduces rpm and explains the application of RPM manual installation and query with examples;

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Text:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Rpm is the abbreviation of red hat package manager, which originally means red hat package management. As the name suggests, it is the package management contributed by red hat; It is adopted in the mainstream distribution versions such as Fedora, RedHat, Mandriva, SUSE and yellowdog, as well as the distribution versions secondary developed on the basis of these versions;

What does the RPM package contain? It contains an executable binary program, which is similar to the. EXE file in the windows software package; The RPM package also includes the files required for the program to run, which is similar to the windows software package. For the operation of windows programs, there are other files besides. Exe files;

An application program in an RPM package sometimes needs other specific version files in addition to its own additional files to ensure its normal operation, which is the dependency of the software package; Dependencies are not unique to Linux, but also exist in Windows operating system; For example, when we run 3D games in Windows system, he may prompt to install direct 9; The principles of Linux and windows are similar;

Software installation flow chart:

 

Scope of use:

1. This article describes the RPM management software. Make is used for the source code package of file.tar.gz or file.tar.bz2; The software installed by make install is invalid;
2. When installing the software, it is best to use the system software package management tools provided by their respective distributions. For Fedora / RedHat, you can refer to the following articles;

1) Fedora system management software package tool system config packages can easily add and remove the software packages provided by the system installation disk. For details, see Fedora software package manager system config packages

2) RedHat system management software package tool. The new system should be RedHat config packages. The usage is the same as Fedora package manager system config packages;

3) Apt + synaptic software package online installation, removal and upgrade tools; Usage: install or upgrade Fedora Core 4.0 software package online with apt + synaptic
4) Yum software package online installation, upgrade and removal tools; Usage: Fedora / RedHat online install update package, yum or up2date

5) All Yum and apt tutorials apt and yum

At present, apt and Yum are very mature. It is recommended that we use apt or Yum when installing the software; If installing the software package provided by the system disk, you can use system config packages or RedHat config packages;

1、 Purpose of RPM package management;

1. Can install, delete, upgrade and manage software; Of course, it also supports online installation and software upgrade;
2. Through RPM package management, you can know which files the software package contains and which software package a file in the system belongs to;
3. You can query whether the software package in the system is installed and its version;
4. As a developer, you can package your own programs as RPM packages and publish them;
5. Software package signature import, verification and signature release of GPG and MD5
6. Dependency check to see if any software package disturbs the system due to incompatibility;

2、 Access to rpm;

The installation, deletion and update of RPM software can only be used with root permission; Any user can operate the query function; If ordinary users have the permission to install the directory, they can also install it;

3、 A simple usage of rpm;

In addition to the package manager, we can also install it through the RPM command; Can all software packages be installed through the RPM command? No, the file ends with the suffix. Rpm; Sometimes we find file.rpm on some websites and use rpm to install it;

1) Initialize RPM database;

Querying whether an RPM package is installed through the RPM command is also completed through the RPM database; Therefore, we should often use the following two commands to initialize the RPM database;

[[email protected] beinan]# rpm –initdb
[[email protected] beinan]# rpm –rebuilddb

Note: this will take a long time;

Note: these two parameters are extremely useful. Sometimes the RPM system has problems and cannot be installed and queried. Most of them have problems here;

2) Query function of RPM package management:

Command format

rpm {-q|–query} [select-options] [query-options]

The query function of RPM is extremely powerful and one of the most important functions; For more detailed examples, please refer to #man rpm

1. Query of installed software in the system;

1) Query the installed software of the system;

Syntax: RPM – Q software name

give an example:

[[email protected] beinan]# rpm -q gaim
gaim-1.3.0-1.fc4

-Q is — query, which means “ask” in Chinese. This command indicates whether GAIM is installed in the system; If installed, there will be information output; If it is not installed, the information that GAIM is not installed will be output;

View all installed packages in the system and add the – a parameter;

[[email protected] RPMS]# rpm -qa

If you view in pages, add a pipeline | and more command;

[[email protected] RPMS]# rpm -qa |more

Find a software in all installed software packages, such as GAIM; It can be extracted with grep;

[[email protected] RPMS]# rpm -qa |grep gaim

The above function is the same as the result of RPM -q GAIM output;

2) Query which software package an installed file belongs to;

Syntax RPM – QF file name

Note: the absolute path of the file name should be indicated

give an example

[[email protected] RPMS]# rpm -qf /usr/lib/libacl.la
libacl-devel-2.2.23-8

3) Query where the installed software packages are installed;

Syntax: RPM – QL software name or rpm rpmquery – QL software name
give an example:

[[email protected] RPMS]# rpm -ql lynx
[[email protected] RPMS]# rpmquery -ql lynx

4) Query information about an installed package

Syntax format: RPM -qi software name
give an example:

[[email protected] RPMS]# rpm -qi lynx

5) Check the configuration file of the installed software;

Syntax format: RPM – QC software name
give an example:

[[email protected] RPMS]# rpm -qc lynx

6) View a document of installed software. Installation location:

Syntax format: RPM -qd software name

give an example:

[[email protected] RPMS]# rpm -qd lynx

7) Check the software packages and files that the installed software depends on;

Syntax format: RPM – QR software name

give an example:

[[email protected] beinan]# rpm -qR rpm-python

Query the summary of installed software: for a software package that has been installed, we can combine a series of parameters; For example, RPM – Qil; For example:

[[email protected] RPMS]# rpm -qil lynx

2. For viewing packages that are not installed:

The premise of viewing is that you have a. RPM file, that is, viewing the existing software file.rpm, etc;

1) View the purpose, version and other information of a software package;

Syntax: RPM – QPI file.rpm

give an example:

[[email protected] RPMS]# rpm -qpi lynx-2.8.5-23.i386.rpm

2) View the files contained in a software package;

Syntax: RPM – QPL file.rpm
give an example:

[[email protected] RPMS]# rpm -qpl lynx-2.8.5-23.i386.rpm

3) View the location of the documentation of the software package;

Syntax: RPM – QPD file.rpm

give an example:

[[email protected] RPMS]# rpm -qpd lynx-2.8.5-23.i386.rpm

5) View the configuration file of a software package;

Syntax: RPM – QPC file.rpm
give an example:

[[email protected] RPMS]# rpm -qpc lynx-2.8.5-23.i386.rpm

4) View the dependencies of a package

Syntax: RPM – QPR file.rpm

give an example:


[[email protected] archives]# rpm -qpR yumex_0.42-3.0.fc4_noarch.rpm
/bin/bash
/usr/bin/python
config(yumex) = 0.42-3.0.fc4
pygtk2
pygtk2-libglade
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
usermode
yum >= 2.3.2

3) Installation, upgrade and deletion of software package;

1. Install and upgrade an RPM package;

[ [email protected] Beinan]#rpm – VIH file.rpm note: This is used to install a new RPM package;
[ [email protected] Beinan]#rpm – uvh file.rpm note: This is used to upgrade an RPM package;

If there are dependencies, please solve them. In fact, the software package manager can solve dependencies well. Please see the introduction of the software package manager above; If you can’t find the dependent package in the package manager; The dependency can only be solved by compiling the package it depends on, or forced installation;

Syntax structure:

[[email protected] beinan]# rpm -ivh file.rpm –nodeps –force
[[email protected] beinan]# rpm -Uvh file.rpm –nodeps –force
For more parameters, see man rpm

Example application:

[[email protected] RPMS]# rpm -ivh lynx-2.8.5-23.i386.rpm
Preparing… ########################################### [100%]
      1:lynx ########################################### [100%]
[[email protected] RPMS]# rpm -ivh –replacepkgs lynx-2.8.5-23.i386.rpm
Preparing… ########################################### [100%]
      1:lynx ########################################### [100%]

Note: – the – replacepkgs parameter is to re install the installed software; Sometimes there is not much need;

Test installation parameter — test, used to check dependencies; Not a real installation;

[[email protected] RPMS]# rpm -ivh –test gaim-1.3.0-1.fc4.i386.rpm
Preparing… ########################################### [100%]
If the new version is downgraded to the old version, add the — oldpackage parameter;


[[email protected] RPMS]# rpm -qa gaim
gaim-1.5.0-1.fc4
[[email protected] RPMS]# rpm -Uvh --oldpackage gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]
  1:gaim ########################################### [100%]
[[email protected] RPMS]# rpm -qa gaim
gaim-1.3.0-1.fc4

Specify the installation directory for the software package: add the – relocate parameter; The following example is to install gaim-1.3.0-1.fc4.i386.rpm in the / opt / GAIM directory;


[[email protected] RPMS]# rpm -ivh --relocate /=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]
  1:gaim ########################################### [100%]
[[email protected] RPMS]# ls /opt/
gaim

Specify the installation directory for the software package: add the – relocate parameter; The following example is to install lynx-2.8.5-23.i386.rpm in / opt / lynx directory;

[[email protected] RPMS]# rpm -ivh –relocate /=/opt/lynx –badreloc lynx-2.8.5-23.i386.rpm
Preparing… ########################################### [100%]
1:lynx ########################################### [100%]

How do we call the program installed in the specified directory? General execution programs are placed in the bin or SBIN directory of the installation directory; Look at the following example; If there is an error output, make the corresponding link and use ln – S;

[[email protected] RPMS]# /opt/lynx/usr/bin/lynx
Configuration file /etc/lynx.cfg is not available.
[[email protected] RPMS]# ln -s /opt/lynx/etc/lynx.cfg /etc/lynx.cfg
[[email protected] RPMS]# /opt/lynx/usr/bin/lynx www.linuxsir.org

2. Delete an RPM package;

First, you should learn to query RPM packages; Please see the previous instructions;

[ [email protected] Beinan]#rpm – e package name

For example, I want to remove the lynx package. The complete operation should be:

[[email protected] RPMS]# rpm -e lynx
If there are dependencies, you can also use — nodeps to ignore the check of dependencies to delete them. But try not to do so. It is best to use the package manager systerm config packages to delete or add software;

[[email protected] beinan]# rpm -e lynx –nodeps

4、 Import signature:

[ [email protected] Rpms]# RPM — import signature file

give an example:

[[email protected] fc40]# rpm –import RPM-GPG-KEY
[[email protected] fc40]# rpm –import RPM-GPG-KEY-fedora

For details on the signature function of RPM, see man rpm

5、 RPM management pack manager supports network installation and query;

For example, we want to query and install software packages through an image of Fedora Core 4.0;

Address:
http://mirrors.kernel.org/fedora/core/4/i386/os/Fedora/RPMS/

give an example:

Command format:

RPM parameter HTTP or FTP address of RPM package file
# rpm -qpi http://mirrors.kernel.org/fedora/core/4/i386/os/ Fedora/RPMS/gaim-1.3.0-1.fc4.i386.rpm
# rpm -ivh http://mirrors.kernel.org/fedora/core/4/i386/os/ Fedora/RPMS/gaim-1.3.0-1.fc4.i386.rpm
Draw inferences from one instance;

6、 A supplement to the query of the installed software package;

[[email protected] RPMS]# updatedb
[ [email protected] Rpms]# locate software name or file name

Through updatedb, we can use locate to query where some software has been installed; When the system is installed for the first time, updatedb shall be executed, and it shall also be executed every other period of time; To keep the installed software library up to date; Updatedb is owned by slocate software package; If you don’t have this command, you have to install slocate;

give an example:

[[email protected] RPMS]# locate gaim

7、 Extract files from RPM software package;

Command format: rpm2cpio file.rpm | CPIO – div

give an example:
[[email protected] RPMS]# rpm2cpio gaim-1.3.0-1.fc4.i386.rpm |cpio -div

The extracted files are in usr and etc in the active operation directory;

In fact, it is not as convenient to extract files as to specify the installation directory to install software; You can also extract files;

Specify the installation directory for the software package: add the – relocate parameter; The following example is to install gaim-1.3.0-1.fc4.i386.rpm in the / opt / GAIM directory;


[[email protected] RPMS]# rpm -ivh --relocate /=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]
  1:gaim ########################################### [100%]
[[email protected] RPMS]# ls /opt/
gaim

It can also be seen at a glance; All files of GAIM are installed in / opt / GAIM. We just back up the GAIM directory and remove GAIM; This is actually a little usage of extracting files;

8、 Configuration file of rpm;

The configuration file of RPM package management is rpmrc, which can be found in our own system; For example, the rpmrc file in Fedora Core 4.0 is located in;


[[email protected] RPMS]# locate rpmrc
/usr/lib/rpm/rpmrc
/usr/lib/rpm/redhat/rpmrc

We can view it through RPM — showrc; We have to learn the details ourselves. Oh… Don’t ask me, I don’t understand; As long as you read this article and think it is useful to you, your level is about the same as me; Our level is the same, so I can’t help you; Please understand;

9、 Usage of src.rpm:

Introduction to using file.src.rpm

Postscript: I have written a lot about the software package management in the Fedora / RedHat introductory tutorial; At present, there is a lack of methods to install software through the source package and a summary document; I want to make it up in the last two days. I have written these two articles before; Just rearrange it and post it;

At my level, writing Fedora introductory course is extremely laborious, and can only be improved and supplemented bit by bit; The tutorial I wrote is for novices who know nothing about Linux; Example applications account for most of the tutorials; I found that without examples, novices might as well look at man; Can see man, of course, is not a novice;

I often watch some brothers’ questions on the forum, although I can cope with them in the past; But if you want to make it more convenient, you might as well write a system introduction tutorial; Although it takes a little longer;

PS: Linux RPM delete command

Command format:

rpm -e ( or –erase) options pkg1 … pkgN

parameter

Pkg1… Pkgn: package to delete

Detailed options

–Test executes only deleted tests

–Nosripts does not run pre – and post install scripts

–Nodeps does not check for dependencies

General options

-VV display debugging information

–Root < path > let RPM take the path specified by < path > as the “root directory”, so as to pre install the program and post install it

All programs will be installed in this directory

–Rcfile < rcfile > set the rpmrc file to < rcfile >

–Dbpath < Path > set the path where the RPM data inventory is located to < Path >