Detailed description of Linux rpm command parameters and rpm usage

Source: Internet
Author: User
Tags gpg

Detailed description of Linux rpm command parameters and rpm usage
Zookeeper


[Introduction and application]



RPM is a RedHat Package Manager (RedHat Package management tool) similar to "Add/delete programs" in Windows"

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

Common command combinations:

 


-Ivh: the installation progress is displayed. -- install -- verbose -- hash
-Uvh: Upgrade the software package -- Update;
-Qpl: lists the file information in the RPM Package [Query Package list].
-Qpi: lists the RPM Package description [Query package install Package (s)];
-Qf: Find the RPM package of the specified File [Query File];
-Va: Check all RPM software packages and find the missing file [View Lost].
-E: delete a package

 

 


Copy code

Rpm-q samba // query whether the program is installed

Rpm-ivh/media/cdrom/RedHat/RPMS/samba-3.0.10-1.4E.i386.rpm // install by path and display progress
Rpm-ivh -- relocate/=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm // specify the installation directory

Rpm-ivh -- test gaim-1.3.0-1.fc4.i386.rpm // used to check dependencies; not a real installation;
Rpm-Uvh -- oldpackage gaim-1.3.0-1.fc4.i386.rpm // New Version downgrade to old version

Rpm-qa | grep httpd # [search for whether the specified rpm package is installed] -- all search * httpd *
Rpm-ql httpd # [search for rpm packages] -- list all File Installation Directories

Rpm-qpi Linux-1.4-6.i368.rpm # [view rpm package] -- query -- package -- install package information
Rpm-qpf Linux-1.4-6.i368.rpm # [view rpm package] -- file
Rpm-qpR file. rpm # [View package] dependency
Rpm2cpio file. rpm | cpio-div # [Extract files]

Rpm-ivh file. rpm # [install a new rpm] -- install -- verbose -- hash
Rpm-ivh

Rpm-Uvh file. rpm # [upgrade an rpm] -- upgrade
Rpm-e file. rpm # [delete an rpm package] -- erase

Copy code

Common parameters:

Install/Upgrade/Erase options:


Copy code

-I, -- install package (s)
-V, -- verbose provide more detailed output
-H, -- hash print hash marks as package install( good with-v)
-E, -- erase (uninstall) package
-U, -- upgrade = <packagefile> + upgrade package (s)
-- Replacepkge forcibly installs the software package no matter whether the software package is installed or not.
-- Test installation test, not actually installed
-- Nodeps forcibly installs software packages regardless of their Dependencies
-- Force ignores conflicts between software packages and files

Query options (with-q or -- query ):
-A, -- all query/verify all packages
-P, -- package query/verify a package file
-L, -- list files in package
-D, -- docfiles list all documentation files
-F, -- file query/verify package (s) owning file

Copy code

RPM source code packaging and Installation

Files ending with. src. rpm are packaged from the source code of the Software. to install such RPM packages, you must run the following command:

 


Rpm -- recompile vim-4.6-4.src.rpm # This command will unpackage the source code and compile and install it if the user uses the command:

Rpm -- rebuild vim-4.6-4.src.rpm # After installation is complete, the compiled executable files are repackaged into the i386.rpm RPM package.

 

I do not like to write complicated things. If you are in trouble, 'but as a reference,' I also switched to a cool man's 'write is really comprehensive'


Author: North South
From: LinuxSir. Org
Abstract: RPM is the abbreviation of Red Hat Package Manager. It was originally intended to manage the Red Hat software Package. This article introduces RPM and describes the applications such as manual installation and query of RPM Based on instances;


++ ++
Body:
++ ++


RPM is the abbreviation of Red Hat Package Manager. It is intended to manage Red Hat software packages. As the name suggests, it is the software Package management contributed by Red Hat; mainstream Release versions such as Fedora, Redhat, Mandriva, SuSE, and YellowDog, as well as the release versions developed on the basis of these versions;

What are included in the RPM package? There are other files besides the hosts file;

The application in an RPM package sometimes requires files of other specific versions in addition to the additional files it carries to ensure its normality. This is the dependency of the software package; the dependency is not exclusive to Linux, and exists in the Windows operating system. For example, if we run 3D games in Windows, a prompt may be prompted during installation, to install Direct 9; Linux and Windows are similar;

Software Installation flowchart:

 


Scope of use:

1. This document describes the rpmmanaged software. The software installed with make and make install is invalid for the file.tar.gz or file.tar.bz2 source code package;
2. When installing software, it is best to use the system software package management tools provided by the respective releases. For Fedora/Redhat, you can refer to the following articles;

1) Fedora system management software package Tool system-config-packages to conveniently 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, which is used in the same way as Fedora Software Package Manager system-config-packages;

3) Online installation, removal, and upgrade of apt + synaptic software package. Usage: install or upgrade Fedora core 4.0 software package online with apt + synaptic
4) install, upgrade, and remove yum software package online. Usage: Fedora/Redhat online installation and update software package, yum

5) All yum and apt tutorials apt and yum

At present, apt and yum are very mature. We recommend that you use apt or yum when installing the software. If you install the software package provided by the system disk, you can use system-config-packages or redhat-config-packages;


1. Usage of RPM package management;


1. You can install, delete, upgrade, and manage software. Of course, you can also install and upgrade software online;
2. You can use RPM to check which files are included in the software package and which software package the file belongs;
3. check whether or not the software package in the query system is installed and its version;
4. As a developer, You can package your program as an RPM package for release;
5. Import, verify, and release of the software package signature GPG and MD5
6. Check the dependency to see if any software package has disrupted the system due to incompatibility;


2. RPM usage permission;

Only root permissions can be used to install, delete, and update RPM software. Any user can perform operations on the query function. If a common user has the permission to install directories, the RPM software can also be installed;


Iii. Simple rpm usage;

In addition to the Software Package Manager, we can also use rpm commands to install software packages. Can all software packages be installed using rpm commands? No, the file ends with a. rpm suffix. Sometimes we find file. rpm on some websites and install it with rpm;

1) initialize the rpm database;

Run the rpm command to check whether an rpm package is installed. The rpm database is also used. Therefore, we often use the following two commands to initialize the rpm database;


[Root @ localhost beinan] # rpm -- initdb
[Root @ localhost beinan] # rpm -- rebuilddb Note: This takes a long time;

Note: These two parameters are extremely useful. Sometimes the rpm system has a problem and cannot be installed or queried. Most of them have a problem here;

2) query functions of RPM software 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 details, refer to # man rpm.

1. query the software installed in the system;


1) query the installed software;

 

Syntax: rpm-q software name

Example:

 

[Root @ localhost beinan] # rpm-q gaim
Gaim-1.3.0-1.fc4

-Q is -- query, which means "q" in Chinese. This command indicates whether gaim is installed in the system. If gaim is installed, information is output. If gaim is not installed, will output the information that gaim has not been installed;

To view all installed packages in the system, add the-a parameter;


[Root @ localhost RPMS] # rpm-qa

If you view it by PAGE, add another pipeline | and more commands;

[Root @ localhost RPMS] # rpm-qa | more

Find a software in all installed software packages, such as gaim. You can use grep to extract the software;

 

[Root @ localhost RPMS] # rpm-qa | grep gaim

The above function is the same as that output by rpm-q gaim;

2) query the software package of an installed file;

 

Syntax rpm-qf file name

Note: the absolute path of the file name must be specified.
 

Example:


[Root @ localhost RPMS] # rpm-qf/usr/lib/libacl. la
Libacl-devel-2.2.23-8

3) query where all installed software packages are installed;

 

Syntax: rpm-ql software name or rpm rpmquery-ql software name

Example:

 

[Root @ localhost RPMS] # rpm-ql lynx
[Root @ localhost RPMS] # rpmquery-ql lynx

4) query the information of an installed software package

 

Syntax format: rpm-qi software name

Example:


[Root @ localhost RPMS] # rpm-qi lynx

5) Check the configuration file of the installed software;

 

Syntax format: rpm-qc software name

Example:


[Root @ localhost RPMS] # rpm-qc lynx

6) view the installation location of a software installation document:

 

Syntax format: rpm-qd software name

Example:

 

[Root @ localhost RPMS] # rpm-qd lynx

7) Check the software packages and files on which the software is installed;

 

Syntax: rpm-qR software name

Example:


[Root @ localhost 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, such as rpm-qil. For example:


[Root @ localhost RPMS] # rpm-qil lynx


2. View uninstalled software packages:

The premise is that you have a. rpm file, that is, you can view the file. rpm of the existing software;

1) view the purpose and version of a software package;

 

Syntax: rpm-qpi file. rpm

Example:

 

[Root @ localhost RPMS] # rpm-qpi lynx-2.8.5-23.i386.rpm

2) view the files contained in a software package;

 

Syntax: rpm-qpl file. rpm

Example:


[Root @ localhost RPMS] # rpm-qpl lynx-2.8.5-23.i386.rpm

3) view the document location of the software package;

 

Syntax: rpm-qpd file. rpm

Example:


[Root @ localhost RPMS] # rpm-qpd lynx-2.8.5-23.i386.rpm

5) view the configuration file of a software package;

 

Syntax: rpm-qpc file. rpm

Example:


[Root @ localhost RPMS] # rpm-qpc lynx-2.8.5-23.i386.rpm

4) view the dependency of a software package

 

Syntax: rpm-qpR file. rpm

Example:


[Root @ localhost 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 packages;


1. Install and upgrade an rpm package;


 

[Root @ localhost beinan] # rpm-vih file. rpm note: this is used to install a new rpm package;
[Root @ localhost beinan] # rpm-Uvh file. rpm note: this is used to upgrade an rpm package;

If dependency exists, resolve the dependency. In fact, the software package manager can solve the dependency well. See the previous introduction of the Software Package Manager; if you cannot find the dependency package in the package manager, you can only compile the dependent package to solve the dependency or force the installation;

Syntax structure:

 

[Root @ localhost beinan] # rpm-ivh file. rpm -- nodeps -- force
[Root @ localhost beinan] # rpm-Uvh file. rpm -- nodeps -- force

For more parameters, see man rpm

Example application:


[Root @ localhost RPMS] # rpm-ivh lynx-2.8.5-23.i386.rpm
Preparing... ######################################## ### [100%]
1: lynx ####################################### #### [100%]
[Root @ localhost RPMS] # rpm-ivh -- replacepkgs lynx-2.8.5-23.i386.rpm
Preparing... ######################################## ### [100%]
1: lynx ####################################### #### [100%]

Note: The -- replacepkgs parameter is installed again with the installed software. Sometimes it is not necessary too much;

Test the installation parameter -- test, which is used to check the dependency. It is not a real installation;

 

[Root @ localhost RPMS] # rpm-ivh -- test gaim-1.3.0-1.fc4.i386.rpm
Preparing... ######################################## ### [100%]

Downgrade from the new version to the old version, and add the -- oldpackage parameter;

 

[Root @ localhost RPMS] # rpm-qa gaim
Gaim-1.5.0-1.fc4
[Root @ localhost RPMS] # rpm-Uvh -- oldpackage gaim-1.3.0-1.fc4.i386.rpm
Preparing... ######################################## ### [100%]
1: gaim ####################################### #### [100%]
[Root @ localhost RPMS] # rpm-qa gaim
Gaim-1.3.0-1.fc4

Specify the installation directory for the package: add the-relocate parameter; the example below is to specify the gaim-1.3.0-1.fc4.i386.rpm to install in the/opt/gaim directory;

 

[Root @ localhost RPMS] # rpm-ivh -- relocate/=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm
Preparing... ######################################## ### [100%]
1: gaim ####################################### #### [100%]
[Root @ localhost RPMS] # ls/opt/
Gaim

Specify the installation directory for the package: add the-relocate parameter; the example below is to specify the installation of the lynx-2.8.5-23.i386.rpm in the/opt/lynx directory;


[Root @ localhost RPMS] # rpm-ivh -- relocate/=/opt/lynx -- badreloc lynx-2.8.5-23.i386.rpm
Preparing... ######################################## ### [100%]
1: lynx ####################################### #### [100%]


How can we call a program installed in a specified directory? Generally, the execution programs are stored in the bin or sbin directory of the installation directory. Take a look at the example below. If there is an error output, make the corresponding link and use ln-s;

 

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


2. delete an rpm package;


First, you must learn to query the rpm package. Please refer to the previous instructions;

[Root @ localhost beinan] # rpm-e package name

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


[Root @ localhost RPMS] # rpm-e lynx

If there is a dependency, you can also use -- nodeps to ignore the dependency check to delete it. But do not do this as much as possible. It is best to use the software package manager systerm-config-packages to delete or add software;

 

[Root @ localhost beinan] # rpm-e lynx -- nodeps


Iv. Import signature:

[Root @ localhost RPMS] # rpm -- import signature file

Example:

 

[Root @ localhost fc40] # rpm -- import RPM-GPG-KEY
[Root @ localhost fc40] # rpm -- import RPM-GPG-KEY-fedora

For more information about the RPM signature function, see man rpm

5. the RPM Management Package 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/

Example:

Command Format:

 

The http or ftp address of the rpm parameter rpm package file

# RPMS-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.

Let's look at the opposite;


6. supplement the query of installed software packages;


[Root @ localhost RPMS] # updatedb
[Root @ localhost 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 first installed, it needs to execute updatedb and run it every other time to keep the installed software library up-to-date; updatedb is owned by the slocate software package. If you do not have this command, you must install slocate;

Example:

 

[Root @ localhost RPMS] # locate gaim


VII. Extraction of files from the rpm software package;


Command Format: rpm2cpio file. rpm | cpio-div

Example:

[Root @ localhost RPMS] # rpm2cpio gaim-1.3.0-1.fc4.i386.rpm | cpio-div

The extracted files are stored in usr and etc;

In fact, it is better to specify the installation directory to install software. You can also Extract files;

Specify the installation directory for the package: add the-relocate parameter; the example below is to specify the gaim-1.3.0-1.fc4.i386.rpm to install in the/opt/gaim directory;

 

[Root @ localhost RPMS] # rpm-ivh -- relocate/=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm
Preparing... ######################################## ### [100%]
1: gaim ####################################### #### [100%]
[Root @ localhost RPMS] # ls/opt/
Gaim

In this way, all the gaim files are installed in/opt/gaim. We just back up the gaim directory and then unload the gaim. This is actually a usage of extracting files;


8. RPM configuration file;

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


[Root @ localhost RPMS] # locate rpmrc
/Usr/lib/rpm/rpmrc
/Usr/lib/rpm/redhat/rpmrc

You can view the details through rpm -- showrc. Oh... Don't ask me, I don't understand either. As long as you read this article and think it is useful to you, your level is similar to mine. Our level is the same, so I cannot help you. Please understand;

9. Usage of src. rpm:

Introduction to file. src. rpm usage


Note: I have already written a lot of software package management articles in the ora/Redhat getting started tutorial. At present, I still lack methods for installing software through the source code package and a summative document; I want to complete these two articles in the last two days. I have written them before. Just repeat them and paste them out;

From my perspective, it is extremely effort-consuming to write a ora getting started tutorial, which can only be improved and supplemented by 1.1 points. What I wrote was to be a newbie who knew nothing about Linux; in the tutorial, most examples of applications are used. If no instance is available, it is better for a newbie to look at man. If man is available, it is certainly not a newbie;

I often read some brothers' questions on the Forum. Although I can handle some questions in the past, it is better to write a system getting started tutorial to make it easier for everyone; although it takes a little longer;


Linux RPM Command Parameters

Rpm-I-prefix <path> specifies the path
Rpm-I-root <path> default path

In the rpm command of Linux, the parameter used to install the new RPM package software is

In either case, the first is that the installed package version is the same as the package version to be installed, so only-e can uninstall the Installed Package and install it with-ivh. The second is that the new package version is relatively high. You can directly use-Uvh to install and upgrade it.
1) never installed. Install it now
> Sudo rpm-ivh <rpmfile>
2) You have installed it and need to reinstall it (the names and versions are the same)
> Sudo rpm-e <rpmname>
> Sudo rpm-ivh <rpmfile>
3) have been installed, and now upgrade and install (same name, version update)
> Sudo rpm-Uvh <rpmfile>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.