Linux software package Management--rpm Package Manager

Source: Internet
Author: User
Tags gpg sha1

How to install, upgrade, and uninstall software in Linux is an important part of our daily operations. The next CentOS6 system, for example, explains how to manage our packages using the RPM Package Manager, Yum Package Manager, and source code.

I. Relevant background knowledge

Many programs source programs, such as the use of C language source code, to be preprocessed, compiled, compiled, linked to generate a real executable program (binary), before it can be used. To simplify this process, a so-called Package Manager appears. It appears to be the purpose of packaging a compiled program into a file or a limited number of files, can be used to implement installation, uninstallation, upgrade, query and other functions.

A package manager should have the following components:

1. Database: Here the bread includes the software name, version, dependencies, function description, the path to the files generated by the installation, and check code to verify the source and data integrity of the software.

2, the composition of the program list: Here the most important is the software before and after the installation, the script that runs before and after the uninstall.

Why is there a dependency when installing the program?

Because Linux programs or tools are made up of other small programs or gadgets, this is one of the features of Linux. It is because of this feature that we may rely on other programs ' library files and header files when installing a package.

# Use the LDD command in Linux to view a binary program (executable file) following the EIF format [[email protected] ~]# ldd ' which pwd ' = (0x00007fff62df000 0) # refers to the program's starting entry =/lib64/ (0x0000003508400000)/lib64/ (0x0000003507c00000)

Packages generally include: binaries, library files, configuration files, Help files, and so on.

Second, RPM Package Manager

The package Manager in CentOS is rpm (the RPM is packages Manager), with the composition and functionality of on-bread management.

1. RPM Package Naming format

All RPM package files end in. rpm. The specific naming format:


Field Meaning
Name Program Name
Version Program source code number. Represents the major version number, the sub-version number, the release number, respectively
Release The release number of RPM itself, regardless of the release number of the program source code, is used only to identify changes made to the RPM package, and the release also contains the OS for this package
Arch Hardware platforms for: i386, i486, i586, I686,x86_64,powerpc,noarch (dependent on virtual machines)

Example: bash-4.2.3-3.centos6.x86_64.rpm

2, the validity of RPM package is positive

When the package author is finished, it will attach a digital signature to the package, and the verification mainly includes the legitimacy of the source and the integrity of the package.

Specific principle:

The creator of the package uses one-way encryption to extract the signature of the original data, and then encrypts the feature code with its own private key, attaching the original data behind it. The validity of the source is verified by the digital certificate, and the integrity problem is judged by extracting the verification code correctly.

Verification process:

Premise: Must have the reliable mechanism obtains to the package author's public key;

1, the use of the producer's public key to decrypt the encrypted signature, can be decrypted means that the source is legitimate;

2, using the same intent as the creator of the encryption algorithm to extract the original data signature, and the decrypted characteristics of the comparison, the same, it means that the integrity of the problem;

3. RPM Sub-package management

Imagine, for example: A program has a total of 50 small functions, is it packaged in a file to be packaged? If so, we only use 5, 6 features, but installed 50 packages, resulting in wasted space. Therefore, the RPM package provides the functionality of the subcontracting to some extent to solve the problem.

Typically there is a main package that provides basic functionality, and other functions are packaged into different package files for use.

Third, the use of RPM package Manager

RPM Package Manager is implemented using the RPM command (front end tool), which describes the common options for this command from different angles.

1. Install package

To install the LFTP sample.

650) this.width=650; "src=" Http:// "title=" RPM- Ivh.jpg "alt=" Wkiol1pjkjcdjwemaaduu4koeay063.jpg "/>

Of course there is no dependency in the installation process, and if dependencies occur, you need to install the dependent packages.

--test: Whether the software can be installed at this time

650) this.width=650; "src=" Http:// "title=" rpm Test.jpg "alt=" Wkiom1pjkfyxrxnsaac8oh9qc-c192.jpg "/>

Reinstall:--replacepkgs If the original configuration file is modified, it is very likely that the replacement will not be performed, but instead the configuration file that should be installed should be renamed to. rpmnew

If you depend on other packages: 1, resolve dependencies, 2, ignore dependencies can be installed, but may not run; Use the--nodeps parameter. RPM-IVH--nodeps Package file name

2. Uninstalling the Package

Common usage: rpm-e package_name

650) this.width=650; "src=" Http:// "title=" 22222222222222222.jpg "alt=" Wkiom1pjkrthdloraadaxsjmdtw951.jpg "/>

If the other package depends on: 1, all packages that depend on this package are unloaded together, 2, ignoring dependencies can unload, but relying on this package package may not work properly, use the--nodeps parameter.

If the package configuration file has been modified since it was uninstalled, the file will not be uninstalled, but is renamed and retained

3. Upgrade Package

Usage: RPM-UVH | -fvh/path/to/package_file

1. Upgrade or install

-UVH: Install if the package does not exist, upgrade if it exists.

2, Pure Upgrade

-FVH: If the package does not exist then do nothing and upgrade if it exists.

If there are problems with the upgrade, you can use--force: Force the upgrade.

Note: You should not perform an upgrade operation on the kernel, but install it. Because the system allows multiple cores to coexist, in the event of an upgrade failure, the system does not cause problems.

4. Query function

The query function of RPM may be the most used in package management.

1) for installed software

-Q: Query package is installed

-QA: Querying the system for installed packages

650) this.width=650; "src=" Http:// "title=" 111111111111111111.jpg "alt=" Wkiol1pjntidf52haah6qjmhwhw543.jpg "/>

-qi: Query Package description Information

650) this.width=650; "src=" Http:// "title=" 111111111111111111111111111111111111111111111.jpg "alt=" Wkiol1pjn8-dl7ysaajenh0tpyk938.jpg "/>

-QL: List all files installed by the package

650) this.width=650; "src=" "title=" 1.jpg " alt= "Wkiol1pjnwcg9rwzaakpx-s3s7w652.jpg"/>

-QC: List the configuration files installed by the package

-QD: List the Help documents installed by the package

650) this.width=650; "src=" "title=" 33.jpg "alt=" Wkiom1pjnjcbbyu_aaixwkjdbec841.jpg "/>

-Q--scripts: Query the script executed when the software is installed

650) this.width=650; "src=" "title=" 4.jpg " alt= "Wkiol1pjndjwmka_aaeb5g6zvrs133.jpg"/>

-QF: Query which package the file was built by

650) this.width=650; "src=" Http:// "title=" 444444444444444.jpg "alt=" Wkiom1pjnqarfoszaabvsxeljta142.jpg "/>

2) for non-installed software

The query function is the same as installed, just join the-p option.

-PQ-PQI-PQL-PQD-PQC and other parameters, with the above functions.

5. Check

Used to check whether the file attributes generated by the package installation have changed

Rpm-v package_name

[Email protected] packages]# rpm-v lftps.5 .... T. c/etc/lftp.conf# Common properties are as follows: If a property is not changed, it is displayed as. # S file Size differs# M Mode differs (includes permissions and file type) # 5 D Igest (formerly MD5 sum) differs# D Device major/minor number mismatch# L readlink (2) path mismatch# U User ownership diff ers# G Group ownership differs# T mTime differs# P capabilities differ

6, RPM package source legality and integrity test:

Prerequisite: The public key of the creator of the package is imported on the current system

Import: RPM--import/path/to/key_file

# Rpm-qa gpg-pubkey*

Displays all the public keys for the GPG format that has been imported

# Rpm-qi Gpg-pubkey-name

Show details of the public key

650) this.width=650; "src=" Http:// "title=" Qqq.jpg "alt=" Wkiol1pjoyayliyoaayyn70zr7k688.jpg "/>

Check package: Automatic execution during installation

Manual Check:

# Completeness and legality check [[email protected] packages]# rpm-k lftp-4.0.9-1.el6.x86_64.rpm lftp-4.0.9-1.el6.x86_64.rpm:rsa SHA1 (MD5) p GP MD5 ok# does not check the legitimacy of the source: [[email protected] packages]# rpm-k--nosignature lftp-4.0.9-1.el6.x86_64.rpmlftp-4.0.9-1.el6.x86_ 64.RPM:SHA1 MD5 ok# does not check package integrity [[email protected] packages]# rpm-k--nodigest lftp-4.0.9-1.el6.x86_64. RPMLFTP-4.0.9-1.EL6.X86_64.RPM:RSA (MD5) PGP OK

7. Database Rebuilding

Database directory:/var/lib/rpm

650) this.width=650; "src=" Http:// "title=" Qweqw.jpg "alt=" Wkiom1pjo_6gqhgaaallstb-b-i140.jpg "/>

RPM--INITDB: Initialization, if there is no library in advance, will create a new one;

RPM--REBUILDDB: Direct rebuild, overwrite the original database

Summary: Personal sense rpm in the installation of software packages is not much, the general use of query function mostly.

This article is from the "Upstream Cold" blog, please be sure to keep this source

Linux software package Management--rpm Package Manager

Related Article

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: 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.