A detailed description of RPM package management in CentOS

Source: Internet
Author: User

Environment Note: win7+vmware11+centos6.6, use the CentOS6.6 installation CD

RPM Full name is "RedHat package Manager", RPM is the biggest advantage is to install the software first compiled, and packaged into the RPM mechanism of the installation package, through the packaged software in the default database record this software must be installed when the dependency property software, When installed on your Linux host is, RPM will first follow the data in the software to query the Linux host dependency property software is satisfied, if satisfied to install, if not satisfied will not be installed.

Before performing RPM package management, we will first mount the CentOS6.6 CD to this machine:

#mount/dev/cdrom/media/mnt

Next, go to the RPM package directory and we'll see a lot of RPM packages in this directory.

#cd/media/mnt/packages

Let's start with the format of the RPM package. The following is a typical RPM package, from this package we can query the package name, version number, issue number, applicable platform, etc.;

rp-pppoe-3.1-5.x86_64.rpm

Rp-pppoe is the package name;

3.1 for version information;

5 is the number of releases;

X86_64 for the appropriate hardware platform;

RPM is an extension;

RPM Default installation path

/etc directory where some settings files are placed
/usr/bin Some executable files
/usr/lib A library of dynamic functions used by some programs
/usr/share/doc Some basic software manuals and help documentation
/usr/share/man Some mans page files


In the management of RPM package, we mainly from the installation, upgrade, uninstall, query, check and so on several aspects.

1. Installation (install)

Installing the software is root, so it is easy to install the software with RPM to get root to operate the rpm command. For example we want to install xvattr-1.3-18.el6.x86_64.rpm files, we can do this as.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5E/00/wKiom1UooxKA9EXnAACW26FiMx4856.jpg "title=" image 1. PNG "alt=" wkiom1uooxka9exnaacw26fimx4856.jpg "/>

We can know the simple usage of installing RPM, but we can't show the progress of the installation, so we usually use some combination commands to perform the installation.

The meaning of-i:install installation

-V: View more detailed installation Information screen, each additional V, display the installation information will be more detailed

-H: Displays the installation progress with the # number information

such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/FC/wKioL1UopkXANVLEAAEFS4siab8790.jpg "title=" Image 2. PNG "width=" 740 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:740PX;HEIGHT:59PX; "alt=" Wkiol1uopkxanvleaaefs4siab8790.jpg "/>

When installing RPM packages, we can also install multiple RPM packages at the same time, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5E/00/wKiom1Uopf2jH6x6AAFQbzXwZ9s318.jpg "title=" Image 3. PNG "width=" 735 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:62px; "alt=" Wkiom1uopf2jh6x6aafqbzxwz9s318.jpg "/>

Before installing RPM, we can use--test to test whether the software can be installed in the user's Linux environment, to find out whether there is a dependency on the property. The first picture is to install the software normally, the second picture does not install the software properly.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/FC/wKioL1UoqsXSovTjAAC1xM-z3nY202.jpg "title=" Image 4. PNG "width=" 735 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:40px; "alt=" Wkiol1uoqsxsovtjaac1xm-z3ny202.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5E/01/wKiom1UorOuQwaBlAAEx2DrNeXM765.jpg "title=" image 5. PNG "width=" 735 "height=" border= "0" hspace= "0" vspace= "0" style= "width:735px;height:71px;" alt= " Wkiom1uorouqwablaaex2drnexm765.jpg "/>

If we find a problem during installation, or if we already know what will happen, or if you want to install the software, you can use the following parameters to "force" the installation.

--nodeps: Software has an attribute dependency problem that cannot be used when it is installed, but will cause the software to not function properly

--replacefiles: If a software is installed or the version information does not meet Yes, you can use this parameter to overwrite the file directly, but the overwritten file is unrecoverable

--replacepkgs: Reinstall and overwrite the original file

--force: Forced installation

--oldpackage: The advanced version of the package is not available, so the downgrade uses the

--relocate: Modifying the installation path

During the installation process, it is recommended to use the-IVH parameter to install the line, if the installation process found a problem, one to find out the problem, do not use "brute force installation Method", that is,--force to force the installation.

2. Upgrade (Upgrade/freshen)

RPM Installation upgrade is also relatively simple, is to upgrade with-UVH or-FVH, but the meaning of-u and-f is not the same.

-UVH: After the software is not installed, the system will be installed directly, if the following software has installed an older version, the system automatically updated to the new version, for example, has installed the old versions, perform-UVH, the system automatically updated.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/FC/wKioL1Uos4nj9vwcAAJuV5ScWBI685.jpg "title=" image 6. PNG "width=" 735 "height=" 191 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:191px; "alt=" Wkiol1uos4nj9vwcaajuv5scwbi685.jpg "/>

-FVH: If the next software is not installed on your Linux system, then the software will not be installed, that is, only the software installed in the Linux system is upgraded, for example, if the old version is not installed, the system will not be upgraded automatically.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/FC/wKioL1UotEqgTBrQAACC7fGB_Mg514.jpg "title=" Image 7. PNG "alt=" wkiol1uoteqgtbrqaacc7fgb_mg514.jpg "/>

You can also use special parameters such as test, force, and so on when using the upgrade.

3. Inquiry (query)

RPM in the query, in fact, the location of the query is/var/lib/rpm this directory of database files. The query is to see if a package has been installed, to check all installed packages, to view details about a package, and so on.

(1) query whether a package or some packages are installed, for example

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5E/01/wKiom1UotVXjkeb1AACsHNmDUnc136.jpg "title=" Image 8. PNG "width=" 318 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:318px;height:100px; "alt=" Wkiom1uotvxjkeb1aacshnmdunc136.jpg "/>

(2) query all packages that have been installed, such as

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5E/01/wKiom1UotdnwFNOvAAHg4xLkoOU727.jpg "title=" Image 9. PNG "alt=" wkiom1uotdnwfnovaahg4xlkoou727.jpg "/>

(3) query which package the file is generated by, for example

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5E/01/wKiom1UotrqCYMbIAABXAiA2FbM315.jpg "title=" image 10. PNG "alt=" wkiom1uotrqcymbiaabxaia2fbm315.jpg "/>

(4) Information about package files that have not been installed,

-P: Note the-P option can be used with the parameters of (5)-(12), but-p is used to find information inside an RPM rather than installed software information. such as-qil

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/FD/wKioL1UovjKgzN6aAADn_K5cpIE571.jpg "title=" image 18. PNG "alt=" wkiol1uovjkgzn6aaadn_k5cpie571.jpg "/>

(5) Query the brief description of a package, for example

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/FC/wKioL1UoudPQ_dHWAASoXySg4UA373.jpg "title=" image 11.png "width=" 735 "height=" 277 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:735PX;HEIGHT:277PX; "alt=" WKIOL1UOUDPQ _dhwaasoxysg4ua373.jpg "/> (6) Queries a list of files generated by a package installation, such as

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5E/01/wKiom1UouQfigxdUAAI54d7NBC4786.jpg "title=" image 12. PNG "alt=" wkiom1uouqfigxduaai54d7nbc4786.jpg "/>

(7) Query all configuration files generated after the installation of a package, for example

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5E/01/wKiom1UouaGwoCfVAACOFFmPlK4069.jpg "title=" image 13.png "alt=" wkiom1uouagwocfvaacoffmplk4069.jpg "/>

(8) Query all Help files generated after a package installation is complete

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5E/01/wKiom1UoufSTgHcLAAEy_nJH1x8237.jpg "title=" image 14. PNG "alt=" wkiom1uoufstghclaaey_njh1x8237.jpg "/>

(9) To view changelog information that changes with the version when a package is made

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5E/01/wKiom1UounuxIacmAADotuutOSw476.jpg "title=" image 15.png "alt=" wkiom1uounuxiacmaadotuutosw476.jpg "/>

(10) Inquire about the capabilities provided by a package;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/FC/wKioL1UovByCIEpxAACri4r3XI8150.jpg "title=" image 16.png "alt=" wkiol1uovbyciepxaacri4r3xi8150.jpg "/>

(11) To inquire about the capabilities that a package relies on;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5E/01/wKiom1Uou4zAt59pAAC3RhXjxKI481.jpg "title=" image 17. PNG "alt=" wkiom1uou4zat59paac3rhxjxki481.jpg "/>

(12) Query execution script when installing or uninstalling a package

Rpm-q--scripts Package_name

There are four types of scripts:

Preinstall: script executed before the installation process starts

Postinstall: Scripts executed after the installation process is complete

Preuninstall: script executed before uninstallation starts

Postinstall: script executed after uninstallation process is complete

4. Verification and digital certificate (verify/signature)

Verify: The files generated after the query package installation have changed, we use the-v option, common options:

-VF: Lists If a file has been altered

-VP: The file name is appended, and files that may have been altered within the software are listed

-va: List all the files that have been changed on the current system

For example

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5E/01/wKiom1Uov1yRouujAABQgJuwMN8084.jpg "title=" image 19. PNG "alt=" wkiom1uov1yrouujaabqgjuwmn8084.jpg "/>

In the We found the letter C preceded by a string of strings, C in front of the 8 information is:


S File size differs: whether the size of the file has been changed

M Mode differs: The type of file or whether the properties of the file have been changed

5 Digest (formerly MD5 sum) differs:md5 The content of this kind of fingerprint code is different

D device Major/minor number mismatch: whether the primary/secondary code of the device has changed

L Readlink (2) path mismatch:link paths have been changed

U User ownership differs: File owner has been changed

G group ownership differs: File user group has been changed

T MTime differs: The file creation time has been changed

C represents the meaning of "configfile", that is, the file type, including

C: Settings file

D: Documentation

G: "Ghost" file

L: Authorization File

R: Readme File

Digital certificates: You can verify the source legitimacy and data integrity of RPM packages. In this article, we use the Centos6.6 CD-ROM, so we introduce the source and completeness of the packages in the verification CD.

#rpm--import rpm-gpg-key-centos-6

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5E/01/wKiom1Uow4_gDmMwAACytpRsrpI305.jpg "title=" image 20. PNG "alt=" wkiom1uow4_gdmmwaacytprsrpi305.jpg "/>

If OK is displayed, the RPM package can be used and installed.

Other common options for digital certificates:

--nosignature: Does not check the legitimacy of the source

--nodigest: Do not check integrity

5. Unload and Rebuild Database (ERASE/REBUILDDB)

Uninstall: Remove a package that has already been installed, such as

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5E/02/wKiom1UoxbqzL_HxAACspQ2tDIE036.jpg "title=" image 21. PNG "alt=" wkiom1uoxbqzl_hxaacspq2tdie036.jpg "/>

Common options for uninstallation

--nodeps: Ignoring dependencies

--allmatches: If a package installs multiple versions at the same time, this option is uninstalled all at once

--test: Test Uninstall, Dry-run mode;

Note: If the package configuration file has been modified since it was uninstalled, this file is usually not deleted, but is renamed (plus suffix. rpmsave) to be retained

Rebuilding the database: Because RPM files are often installed, deleted, upgraded, and so on, some operations may cause file corruption within the RPM database/var/lib/rpm/, so we sometimes need to rebuild the database.

--INITDB: Initializes the database, that is, the database does not exist at all, you can create a new

--REBUILDDB: This library is rebuilt directly regardless of the current data (this is a dangerous operation)

This article from the "Linux Learning" blog, declined reprint!

A detailed description of RPM package management in CentOS

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