Rpm package management in CentOS

Source: Internet
Author: User
Tags gpg

Rpm package management in CentOS

I. Overview

RPM is the abbreviation of RPM Package Manager. u. s. e. the distribution versions of Linux, such as Turbo Linux, are all adopted. software packages packaged based on this standard provide convenience for the use of software.

Ii. rpm package composition

(Note: the program name should be replaced by the APP)

Package format: including binary program, library file, configuration file, and help file

Directory of the package installation file:

1. binary program:/bin,/sbin;/usr/bin,/usr/sbin;/usr/local/bin,/usr/local/sbin; or in a custom directory: /usr/local/APP/bin,/usr/local/APP/sbin

2. library files (Development Library and Runtime Library): stores the 64-bit system library files in/lib64;/usr/lib64;/usr/local/lib64; or the custom directory/usr/local/APP/lib64

3. Help File man:/usr/share/man,/usr/local/share/man, or custom directory/usr/local/APP/man

In addition, the help files of the package include man, info, and doc.

Note: Some special applications do not allow users to directly execute them in their own command lines unless they use absolute paths. These programs are placed in libexec (located at/usr/;/usr/local/Or the User-Defined directory/usr/local/App. In addition, some third-party applications are installed on/opt by default.Directory

Iii. RPM package manager

The RPM package manager is used to package compiled programs into a file or a limited number of files for installation, uninstallation, upgrade, query, verification, database management, and other functions. It consists of a list of databases and programs.

1. database content:

Program name and version

Dependency

Function Description

Install the generated file path and Verification Code

2. program composition list:

File List

Installation and uninstallation scripts, including pre-installation scripts, post-installation steps, pre-installation scripts, post-installation scripts

4. Use the rpm package. Including installation, uninstallation, upgrade, query, validation note, package source legality and integrity check

1. Package naming, subcontracting mechanism awareness, and how to obtain rpm packages

(1) package naming format

Source code name: program name-version: name-version.tar. {gz, bz2, xz}

Version: major. minor. release Main version number. minor version number. Trim number

Example: bash-4.2.3.tar.gz

Rpm package name: program name-version number-package revision number. Hardware Platform: name-version-relase.arch.rpm

Version: Same as source code

Release: Package correction number. The release number of rpm itself, which is irrelevant to the release number of the program source code. It is only used to identify revisions to different rpm packages.

Arch: Suitable for hardware platforms

X86: i386, i8.0, i586, i686, etc.

X86_64: x86_64

Powerpc: ppc

Noarch: dependent on virtual machines (Interpreter)

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

(2) Subcontracting Mechanism

A program has a certain number of functions. These features are packaged into the main package and multiple sub-packages.

Core Package (main package): Same name as source program

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

Sub-package: add the function name after the name

For example:

Package name with a function: bash-a-4.2.3-3.centos7.x86_64.rpm

Function name related to secondary development: bash-devel-4.2.3-3.centos7.x86_64.rpm

(3) how to obtain the rpm package

1. Released CD or Site Server

For example:

Http://mirrors.163.com

Http://mirrors.sohu.com

2. Official Website of the project

Obtain source code and rpm packages

3. Many third-party organizations or individuals create and publish many rpm packages

Http://rpmfind.net

Http://rpm.pbone.net

4. Reliable approaches

EPEL

Fedora-EPEL

2. Common Use Cases of rpm package manager

(Note: The package_name is used instead of package_name)

(1) Installation Package

Command: rpm [option]/.../package_file (the option is followed by the package path)

Command Options:

-I: Installation

-V: displays the installation process.

-Vv: Detailed installation process is displayed.

-Vvv: displays the detailed installation process.

-H: Use # To display the installation progress

-- Test: Only for testing, not for Installation

Example: rpm-ivh -- test/media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm

-- Nodeps: Ignore dependency

Note: It can be installed but may not run.

-- Replacepkgs reinstall

Note: If the original configuration file has been modified, it is likely that the replacement will not be executed, but the generated configuration file should be installed again.

Name it. rpmnew

(2) uninstall the Software Package

Command: rpm [option] package_name (directly following the package name after option)

Command Options:

-E: erase uninstall

-- Nodeps: Ignore dependency unload

Note: 1. It can be uninstalled, but dependent on this package may not run properly;

2. If the package configuration file has been changed after installation, the file will not be uninstalled during uninstallation, but will be renamed and retained for uninstallation. For example:

[Root @ localhost ~] # Rpm-e zsh

Warning:/etc/zprofile saved as/etc/zprofile. rpmsave

(3) Upgrade the Software Package

Command: rpm [option]/.../package_file (the option is followed by the package path)

Command Options:

-Uvh: upgrade or install

-Fvl: upgrade only

-- Force: force update

Note: 1. Dependency may cause version conflicts after upgrade, and other packages dependent on this package may not run properly.

2. You should not upgrade the kernel, but install the system to allow coexistence of multiple kernels

(4) query related software packages

1. Check whether the software package has been installed.

Command: rpm-q package_name...

2. query all installed packages

Command: rpm-qa

In addition, you can filter out the specified installed packages by criteria. For example, you can query the installed kernel: rpm-qa | grep '^ kernel *'

3. query the description of the installed package

Command: rpm-qi package_name

4. query the files generated by a package installation.

Command: rpm-ql package_name

For more details:

(1) query the configuration files generated by an installed installation package.

Command: rpm-qc package_name

(2) query the documents generated by an installed installation package (Help File)

Command: rpm-qd package_name

(3) query the script of the package

Command: rpm-q -- scripts package_name

(4) query which package is generated by which a file is installed.

Command: rpm-qf/path/to/some_file

Query uninstalled packages:

Command: rpm [option]/path/to/package_file

Command Options:

-Qpi: queries the description of an installation package.

-Qpl: query the files generated when an installation package is not installed.

-Qpc: query the configuration files generated when an installation package is not installed.

-Qpd: queries the documents generated when an installation package is installed.

(5) Verification

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

Command: rpm-V package_name

For example:

[Root @ localhost ~] # Rpm-V zsh

S.5... T. c/etc/zprofile

Meanings of each identifier:

S: file size changed

M: Permission and file type change

5: MD5 verification code changed

D: Change the master and secondary device numbers in the device file

L: readLink path change

U: Owner change

G: Group change

T: The modification time has changed.

P: Function Change

.: Indicates that the property of the installation file has not changed.

(6) Check the legitimacy and integrity of rpm package sources

Take the rpm package inspection of the released CD as an example:

1. Import the public key of the package producer on the current system

Command: rpm -- import/media/cdrom/RPM-GPG-KEY-CentOS-6

Display All imported public keys in gpg format:

Command: rpm-qa gpg-pubkey *

Display the key details:

Command: rpm-qi/media/cdrom/RPM-GPG-KEY-CentOS-6

Note: After the public key is imported, the package prototype and validity check will be executed during the installation of the software package.

2. Manual check

For example, check the package zsh:

[Root @ localhost ~] # Rpm-K/media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm

/Media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK

Do not check the package integrity:

[Root @ localhost ~] # Rpm-K -- nodigest/media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm

/Media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm: rsa (md5) pgp OK

Do not check the source validity:

[Root @ localhost ~] # Rpm-K -- nosignature/media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm

/Media/cdrom/Packages/zsh-4.3.10-7.el6.x86_64.rpm: sha1 md5 OK

(7) database Reconstruction

If the database is damaged, the database must be rebuilt.

Note: the location of the database directory/etc/var/lib/rpm

Reconstruction Method:

1. Initialization. If no database exists, a new one will be created. If yes, no new one will be created:

Command: rpm -- initdb

2. Directly rebuild and overwrite the original database

Command: rpm -- rebuilddb

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.