CentOS system package manager [rpm, yum]

Source: Internet
Author: User
Tags yum repolist

CentOS system package manager [rpm, yum]
The Package Manager packs compiled files into one or a limited number of files for convenient program management such as installation, uninstallation, upgrade, query, and validation. Common centos program managers include rpm and yum.

Rpm:Redhat package manager, RPM is Package Manager

Rpm is a software package management method developed by RedHat. With rpm, we can easily install, query, uninstall, and upgrade software. However, the dependency between rpm packages is often cumbersome, especially when software is grouped by multiple rpm packages.

RPM package naming example, bash-4.3.2-1.centos6.x86_64.rpmRpm ApplicationInstall

Rpm {-I | -- install} [install-options] PACKAGE_FILE...

-I Installation

-V: displays detailed information, which can be used together to view more detailed information, such as-vv and-vvv.

-H: displays the progress. 50 # is used as the progress bar.

We generally use-ivh in combination to install the rpm package.

-- Nodeps cancel dependency

-- Replacepkgs reinstall

-- Test the installation instead of the actual installation

Example:

[Root @ localhost ~] # Rpm-ivh package. rpm

Upgrade

Rpm {-U | -- upgrade} [install-options] PACKAGE_FILE...

If an earlier version of the package exists, upgrade and install the package. If not, install the package directly.

Rpm {-F | -- freshen} [install-options] PACKAGE_FILE...

If an earlier version of the package exists, upgrade and install the package. If not, terminate the installation.

We usually use-Uvh and-fvl together to install the rpm package.

[Install-options]

-- Oldpackage downgrade Installation

-- Force ignores conflicts and enforces them.

Note:

Do not upgrade the kernel package. linux supports coexistence of multiple versions of the kernel. Therefore, you can directly install the new version of the kernel;

If the configuration file of the original package has been changed after installation, during the upgrade, the new version does not directly overwrite the files of the old version. Instead, the new version will be replaced with a suffix. rpmnew) is retained;

Example:

[Root @ localhost ~] # Rpm-Uvh package. rpm

Uninstall

Rpm {-e | -- erase} [-- allmatches] [-- nodeps] [-- noscripts] [-- notriggers] [-- test] PACKAGE_NAME...

-- Nodeps ignore dependency

-- Test uninstall test

Example:

[Root @ localhost ~] # Rpm-ev package

Query

Rpm {-q | -- query} [select-options] [query-options]

[Select-options]

1. Check whether the package is installed.

Rpm-q PACKAGE_NAME...

2. query all installed packages

Rpm-qa

3. query which package is installed and generated for a file.

Rpm-qf/path/to/somefile

4. Query Information about uninstalled packages.

Rpm-qp PACKAGE_FILE

[Query-options]

1. query Brief description of a package

Rpm-qi PACKAGE_NAME

2. query the list of all files generated after a package is installed.

Rpm-ql PACKAGE_NAME

3. query the list of all configuration files generated after a package is installed.

Rpm-qc PACKAGE_NAME

4. query the list of all help files generated after a package is installed.

Rpm-qd PACKAGE_NAME

5. query the changelog list information that varies with the version when an rpm package is created.

Rpm-q -- changelog PACKAGE_NAME

6. query the capabilities provided by a package

Rpm-q -- provides PACKAGE_NAME

7. query the capabilities on which a package depends

Rpm-q -- requires PACKAGE_NAME

8. query the script for installing and uninstalling a package.

Rpm-q -- scripts

There are four types of scripts for installation and uninstallation:

Preinstall: script executed before installation

Postinstall: script executed after installation

Preuninstall: script executed before uninstallation

Postuninstall: script executed after uninstallation

Example:

All RPM packages installed in the query system

[Root @ localhost ~] # Rpm-qa

Query the list of files contained in the RPM package

[Root @ localhost ~] # Rpm-qlp package

Query the Help file list contained in the RPM package

[Root @ localhost ~] # Rpm-qdp package

Verification

Rpm {-V | -- verify} [select-options] [verify-options]

Common usage: rpm-V PACKAGE_NAME

After the file is changed, the following information will be prompted during verification:

5: MD5 check value of the file

S: File Size

L: Link file

T: File Creation Time

D: Device File

U: file user

G: file User Group

M: File Permission

Example:

Use vim to modify the yum. conf file and then verify the file.

[Root @ localhost ~] # Rpm-V yum. conf

S.5..... T. c/etc/yum. conf

Package source validity and Integrity Verification

Rpm -- import PUBKEY...

Import key

Rpm {-K | -- checksig} [-- nosignature] [-- nodigest] PACKAGE_FILE...

Verification key

-- Nosignature: do not check the source Validity

-- Nodigest: integrity is not checked

Example:

[Root @ localhost ~] # Rpm -- import/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat -*

[Root @ localhost ~] # Rpm-k/var/ftp/pub/Server/kernel-PAE-2.6.18-194.el5.i686.rpm

/Var/ftp/pub/Server/kernel-PAE-2.6.18-194.el5.i686.rpm: (sha1) dsa sha1 md5 gpg OK

Public Database:/var/lib/rpm

Rebuilding a database

Rpm {-- initdb | -- rebuilddb}

Initialization: -- initdb

If no data exists in advance, it is new. Otherwise, no operation is performed.

Rebuild: -- rebuilddb

Whether or not the current database exists, the existing database is directly rebuilt and overwritten.

Example:

[Root @ localhost ~] # Rpm -- initdb

[Root @ localhost ~] # Rpm -- rebuilddb

Yum:Yellow dog Updater, Modified

The main function is to conveniently Add/delete/update RPM packages. It can automatically solve the dependency problem of packages and facilitate the management of a large number of system updates.

Configure yum Repository

Yum repository configuration file:

Points to the warehouse location and various configuration information. Each yum customer can have multiple available yum warehouses.

The main configuration files include:

/Etc/yum. conf

/Etc/yum. repos. d/*. repo

Advanced usage of yum client Configuration:

1. If you have multiple yum repositories and want to use them first, you can add a line of cost in the configuration file to define the overhead value of the repository. The default value is 1000. The lower the value, the higher the priority.

Example: cost = 400

2. variables can be used when a path is specified in baseurl,

Example: http://mirrors.sohu.com/centos/?releasever/ OS /?basearch

3. You can use the baseurl replacement command with the shortlist command.

Point to a URL. This URL is a text file that stores a large list of backup servers. When you use the yum repository, the list file is obtained, then, use the fastestmirror plug-in to determine which image is the fastest accessed server and use it as the baseurl for this access.

Yum Application

Commands related to the yum Repository

List all available repositories:

# Yum repolist

List all packages:

# Yum list {all | installed | available}

Supports globbing wildcards

Cache Management:

# Yum clean {all | packages}

# Yum makecache

Example:

[Root @ localhost ~] # Yum list

[Root @ localhost ~] # Yum clean

[Root @ localhost ~] # Yum makecache

Install

Yum install PACKAGE_NAME...

-Y: the automatic answer is yes.

To install a program of the specified version:

Yum install PACKAGE-VERSION...

Reinstall the specified package:

Yum reinstall PACKAGE_NAME...

Example:

[Root @ localhost ~] # Yum-y install creatrepo

Upgrade

Yum update PACKAGE_NAME

If multiple version upgrade packages are available and you only want to upgrade to the specified version:

Yum update PACKAGE-VERSION

Downgrade:

Yum downgrade PACKAGE_NAME

Check available upgrades:

Yum check-update

Example:

[Root @ localhost ~] # Yum update createrepo

Uninstall

Yum erase | remove PACKAGE_NAME

Note: Other packages dependent on the specified package will be uninstalled together.

Example:

[Root @ localhost ~] # Yum remove createrepo

Query

Yum list

List all security software

Yum info PACKAGE_NAME

List software package information

Yum search KEYWORD

Fuzzy query of the package name or package's sumary information based on the KEYWORD, including the list of related KEYWORD

Yum provides | whatprovides/path/to/somefile

List the files provided by the Software Package

Example:

[Root @ localhost ~] # Yum list

[Root @ localhost ~] # Yum info createrepo

[Root @ localhost ~] # Yum provides createrepo

Group Management

Show all groups:

Yum grouplist

Displays information about a package group:

Yum groupinfo "GROUP_NAME"

Installation Package group:

Yum groupinstall "GROUP_NAME"

Or

Yum install @ GROUP_NAME can be enclosed in quotation marks without adding them.

Unmount a group:

Yum groupremove "GROUP_NAME"

Yum remove @ "GROUP_NAME"

Upgrade package group:

Yum groupupdate "GROUP_NAME"

Example:

[Root @ localhost ~] # Yum groupremove "Development tools"

Download the rpm package yumdownloader -- resolve PACKAGE_FILE from the yum repository...

-- Destdir DIR

Specify the target directory for download. The current directory is used by default.

-- Urls

Instead of downloading the RPM package, list the URLs to be downloaded.

-- Resolve

When downloading the RPM package, resolve the dependency and download the required software package

-- Source

Instead of downloading the binary RPM package, download the source RPM package

Example:

[Root @ localhost ~] # Yumdownloader -- resolve glances

Extract files from RPM files (use of RPM2CPIO and CPIO)

To download an RPM, you need to check its content instead of installing it. You can use the rpm2cpio command to convert the content into a cpio archive, and then extract some or all files in the package using the cpio command. Convert the bind package and display the extracted files (and directories ). For more information about rpm2cpio and cpio commands, see their manual pages.

Reference: http://blog.chinaunix.net/uid-26435987-id-3399279.html

Example:

[Root @ localhost ~] # Rpm2cpio./bind-9.8.2-0.17.rc1.el6.x86_64.rpm | cpio-idv

The yum command can also install the local rpm package file.

Yum localinstall/path/to/rpm_package_file...

Install the local rpm package

Option:

-- Enablerepo = enable a yum Repository

-- Disablerepo = Disable a yum Repository

Note: The priority is higher than the attribute defined in the/etc/yum. repos. d/*. repo configuration file;

-Y: the automatic answer is yes.

-- Nogpgcheck: the source and integrity of the package are not verified.

Example:

[Root @ localhost ~] # Yum-y localinstall/tmp/repos/glibc-common-2.6.32-358.el6.i386.rpm


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.