RPM command details

Source: Internet
Author: User

I,RPMUsage of 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;

II,RPM;

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,RpmA little simple 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) initializationRpmDatabase;

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)RPMQuery functions of 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

V,RPMThe 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. SlaveRpmThe software package extracts files;
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,RPMConfiguration 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
 

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.