Rpm {-e | -- erase} [-- allmatches] [-- nodeps] [-- noscripts] [-- notriggers] [-- test] PACKAGE_NAME...
QueryRpm {-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
VerificationRpm {-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 VerificationRpm -- 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/rpmRebuilding 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 RepositoryYum 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 ApplicationCommands 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
InstallYum 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
UpgradeYum 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
UninstallYum erase | remove PACKAGE_NAME
Note: Other packages dependent on the specified package will be uninstalled together.
Example:
[Root @ localhost ~] # Yum remove createrepo
QueryYum 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 ManagementShow 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