Introduction to RPM package
RPM package is in the corresponding operating system platform compiled on the package, not compiled is a bunch of source code, many new users of Linux has not been able to or self-compiled source code program is very difficult, so there will be the RPM Package Manager. The use of RPM allows users to easily install, query, uninstall, upgrade and other work. However, the dependencies between RPM packages are often cumbersome, especially when the software is made up of multiple RPM packages.
After the program is compiled generally have four parts, binaries, library files, configuration files, Help files listed below the system's storage path.
Binaries:/bin,/sbin,/usr/bin,/usr/sbin,/usr/local/bin,/usr/local/sbin,/opt/bin,/opt/sbin
Library files:/lib,/lib64,/usr/lib,/usr/lib64,/usr/local/lib,/usr/local/lib64
Configuration files:/etc,/etc/dir,/usr/local/{etc,conf}
Help files:/usr/share/man,/usr/share/doc,/usr/local/share/man
The source code package can be compiled to customize the functionality of the package, the required functionality can be compiled, the unnecessary functionality is not compiled. However, the RPM package is a directly compiled package, in order to enable users to select the required features at the time of installation, discard unnecessary features, will be a program to subcontract, a program will be compiled into a number of different features of the package, let the user choose to install.
How packages are named
appname-version-release.arch.rpm
VERSION:
Major: Major Version number
Minor: Minor version number
Release: Release number
RELEASE: The revision number of the package itself, and sometimes the OS information that is applicable, such as the 2.CENTOS6 in bash-4.3.2-2.centos6.x86_64.rpm
ARCH: the applicable platform
X86:i386, i486, i586, i686
x86_64:x86_64, AMD64
Powerpc:ppc
Noarch: Nothing to do with the platform;
The HTTPD software package is named as follows:
httpd-2.2.15-39.el6.centos.x86_64.rpm
Source of RPM packages
1, the system installation CD-ROM or the official mirror site
Mount Disc: Mount/dev/cdrom/media/cdrom
Official site, Image:
Mirrors.sohu.com
Mirrors.163.com
Mirrors.aliyun.com
2. The official site of the package
3. Third Party organization: Epel
4. Search Engine
Http://rpmfind.net
Http://rpm.pbone.net
http://pkgs.org
RPM Package Management Install Packages
Syntax:rpm {-i|--install}{install-options} package
Options:
-I: Indicates installation package,--install is a long option
-H: To # to indicate installation progress
-V: Displays detailed information during installation
-VV: Show more detailed information
-VVV: Show more detailed information than VV
--test: Do not perform a real installation process, but only report conflicting information
--nodeps: Ignores dependencies. Although it can be installed successfully, it may not work correctly.
--force: Force the installation of the package.
--replacepkgs: Overwrite the installation, reinstall and overwrite the original file.
--relocate: Locate the installation path of the package that allows you to modify the installation path to the new path
--replacefiles: When there are multiple packages installed, the same files may be installed, and you will need to specify the post-installed packages to replace the files installed by the previous package
common combinations for installation :-IVH,-IVVH
Example: Installing ZSH software
[Email protected] packages]# RPM-IVH zsh-4.3.10-7.el6.x86_64.rpmwarning:zsh-4.3.10-7.el6.x86_64.rpm:header V3RSA/ SHA1 Signature, key ID c105b9de:nokeypreparing ... ########################################### [100%] 1:zs H ########################################### [100%]
Dependencies : The most kengdie of the RPM package is the installation of a package, may depend on B, install B depends on C, sometimes a package to the end of the last dozens of hundred or maybe.
Resolving dependencies installation Packages
[Email protected] packages]# RPM-IVH php-5.3.3-38.el6.x86_64.rpmwarning:php-5.3.3-38.el6.x86_64.rpm:header V3RSA/ SHA1 Signature, Key ID c105b9de:NOKEYerror:Failed dependencies:php-cli (x86-64) = 5.3.3-38.el6 is needed by php-5. 3.3-38.el6.x86_64 Php-common (x86-64) = 5.3.3-38.el6 is needed by php-5.3.3-38.el6.x86_64
The above error indicates that the installation of PHP relies on the PHP-CLI package and the Php-common software package, only need to install together will not error.
[Email protected] packages]# RPM-IVH php-5.3.3-38.el6.x86_64.rpm php-cli-5.3.3-38.el6.x86_64.rpm php-common-5.3.3-38.el6.x86_64.rpm
Upgrade Package:
Syntax:rpm {-u|--upgrade} [install-options] package_file ...
-U: Upgrade or install (upgrade if available, no install)
Rpm{-f|--freshen} [install-options] package_file ...
-F: Upgrade (if you have not previously installed the lower version of the package, then you will not perform the upgrade operation)
Options:
--test: Just test to see if it can be upgraded instead of being upgraded.
--nodeps: Ignore dependencies when upgrading
--force: Forced upgrade
--oldpackage: Package Demotion
--relocate: Locate the installation path of the package that allows you to modify the installation path to the new path
--replacefiles: Replace only specified files during installation
Common combination:-UVH,-FVH
Attention:
(1) do not upgrade the kernel, the new version of the kernel may be incompatible with the system.
Linux allows multiple cores to coexist, so you can install several different versions of the kernel directly;
(2) If the package configuration file has been modified after the upgrade, the new version of the file will not overwrite the old version of the configuration file, and the new version of the configuration file renamed (add suffix. rpmnew) after the save.
example : Upgrade zsh, download to the new version of zsh after the package directly execute the following upgrade command
[Email protected] ~]# RPM-UVH zsh-4.3.10-8.el6_5.x86_64.rpm
New zshhttp://mirrors.aliyun.com/centos/6.6/updates/x86_64/packages/
Uninstall:
Syntax:rpm {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] package_name ...
Simple usage:
RPM –e package_name
--nodeps: Ignoring dependencies
--test: Test Uninstall
--allmatches: If a package installs multiple versions at the same time, this option is uninstalled all at once.
Note: If the package configuration file has been modified after installation, when uninstalled, this file is usually not deleted, but is renamed (plus suffix, rpmsave) after it is retained;
Example: uninstalling zsh
[Email protected] ~]# rpm-e zsh
Uninstall only need to execute the uninstall command on the package name, do not need more version and suffix information, so it will be error.
Enquiry:
Query whether a package has been installed, and check all packages that are installed, and view details about a package
Syntax:rpm {-q|--query} [select-options] [query-options]
[select-options] Option Description:
1. Check whether a package or some packages are installed;
RPM –q package_name
Example: If the query has httpd installed, the query results will output the full package name of the httpd.
[Email protected] packages]# rpm-q httpdhttpd-2.2.15-39.el6.centos.x86_64
2. Query all packages that have been installed;
RPM –QA
Note: If you look at all the packages that have been installed, the results of the output will be very large, generally use this option commonly used in two types of functions
(1) query how many RPM packages are installed on the current system
Example: Querying how many packages are installed on the current system
[Email protected] ~]# Rpm-qa | wc-l1032
(2) Use grep to filter the query results to see how many matching packages are available
Example: Querying information about HTTPD related packages currently installed on the system
[Email protected] ~]# Rpm-qa | grep httpdhttpd-tools-2.2.15-39.el6.centos.x86_64httpd-2.2.15-39.el6.centos.x86_64
3. Query for a file is generated by that package installation
RPM –QF
Example: The query/etc/httpd/conf/httpd.conf was installed by that package.
[Email protected] ~]# rpm-qf/etc/httpd/conf/httpd.confhttpd-2.2.15-39.el6.centos.x86_64
4. Query for information about packages that have not been installed
-P
Description: The-p option cannot be used alone and needs to be used in conjunction with the [query-options] parameter.
Example: Querying for information about the MySQL software package
[[email protected] packages]# rpm -pqimysql-5.1.73-3.el6_5.x86_64.rpmwarning: Mysql-5.1.73-3.el6_5.x86_64.rpm: header v3rsa/sha1 signature, key id c105b9de: NOKEYName :mysql Relocations: (not relocatable) version :5.1.73 Vendor: CentOSRelease :3.el6_5 Build Date:Thu 13 Feb 2014 03:42:39 AM CSTInstall date: (not installed) &Nbsp; build host: c6b9.bsys.dev.centos.orggroup :applications/databases Source RPM:mysql-5.1.73-3.el6_5.src.rpmSize :2495591 License:GPLv2 with Exceptionssignature :rsa/sha1, thu 13 feb 2014 03:48:07 am cst, key id 0946fca2c105b9depackager :centos buildsystem Parameter description:
Name: Software name
Version: Release information
Release: Release number
Install Date: The installation time of the package
Group: Groups where packages are located
Size: Sizes
Signature: Package Signature Information
Packager: The producer of the bag
URL: The package source code program can be obtained from there to
Summary: A brief introduction to the package
Relocations: Whether it is relocated to another location
Vendor: Provider
Build Date: The build time of the package
Build Host: Hosts that compile the package
SOURCE rpm: Feed RPM Package
License: License
Description: A detailed description of the package
[query-options] Option Description:
1. Query for brief information about a package
Rpm-qi
2. Querying a list of files generated by a package installation
RPM –QL
Example: Displays a list of files generated by the installation httpd,
[Email protected] packages]# RPM-QL httpd/etc/httpd/etc/httpd/conf/etc/httpd/conf.d/etc/httpd/conf.d/readme/etc/ httpd/conf.d/welcome.conf/etc/httpd/conf/httpd.conf/etc/httpd/conf/magic/etc/httpd/logs/etc/httpd/modules/etc/ Httpd/run ... Too many build lists, omit part of the content ...
3. Query all configuration files after a package installation is complete
RPM –QC
Example: Displays the configuration file after the PHP installation is complete.
[Email protected] ~]# RPM-QC php/etc/httpd/conf.d/php.conf
4. Query the Help file after a package installation is complete
RPM –QD
[Email protected] ~]# RPM-QD HTTPD/USR/SHARE/DOC/HTTPD-2.2.15/ABOUT_APACHE/USR/SHARE/DOC/HTTPD-2.2.15/CHANGES/USR /share/doc/httpd-2.2.15/license/usr/share/doc/httpd-2.2.15/notice/usr/share/doc/httpd-2.2.15/readme/usr/share/ Doc/httpd-2.2.15/versioning/usr/share/man/man8/apachectl.8.gz/usr/share/man/man8/htcacheclean.8.gz/usr/share/ Man/man8/httpd.8.gz/usr/share/man/man8/rotatelogs.8.gz/usr/share/man/man8/suexec.8.gz
5. View changelog information that changes with the version when a package is made, Changelog records what changes have been made to each update of the package
RPM –q –Changelog
[Email protected] ~]# rpm-q-changelog httpd* Wed Oct Johnny hughes<[email protected]>-2.2.15-39.el6.cen Tos-roll in CentOS Branding * Tue, Jan Kaluza <[email protected]>-2.2.15-39-mod_proxy:close Client Co Nnection if the backendcloses connection (#1111410) ... Too much output, omit part of the content ...
6. Query the capabilities provided by a package,
RPM –q –provides
[Email protected] ~]# rpm-q-provides httpdconfig (httpd) = 2.2.15-39.EL6.CENTOSHTTPD-MMN = 20051115httpd-suexec = 2.2.15 -39.el6.centosmod_actions.so () (64bit) mod_alias.so () (64bit) mod_asis.so () (64bit) mod_auth_basic.so () (64bit) ... Too much output, omit part of the content ...
7. Query the capabilities that a package depends on
RPM –q –requires
[Email protected] ~]# rpm-q-requires httpd/bin/bash/bin/sh/etc/mime.types/usr/sbin/useradd apr-util-ldap chkconfig C Onfig (httpd) = 2.2.15-39.el6.centoshttpd-tools = 2.2.15-39.el6.centos ... Too much output, omit part of the content ...
8. Query the script executed when loading and unloading a package
RPM –q –scripts
There are four types of scripts:
Preinstall: script executed before the installation process starts
Postinstall: Scripts executed after the installation process is complete
Prenuinstall: script executed before uninstallation starts
Postuninstall: script executed after uninstallation process is complete
[[email protected] ~]# rpm -q -scripts httpdpreinstall scriptlet ( using /bin/sh): #表示安装前脚本 # add the "Apache" usergetent group apache >/dev/null | | groupadd -g 48-r apachegetent passwd apache >/dev/null | | useradd -r-u 48 -g apache -s /sbin/nologin -d/var/www -c "Apache" apacheexit 0postinstall scriptlet (using /bin/sh): #表示安装后脚本 # register the httpd service/sbin/chkconfig --add httpd/sbin/chkconfig --add htcachecleanpreuninstall scriptlet (using /bin/sh): # Script executed prior to uninstallation if [ $1 = 0 ]; then /sbin/ service httpd stop > /dev/null 2>&1 & nbsp;/sbin/chkconfig --del httpd /sbin/service htcacheclean stop > /dev/null 2>&1 / sbin/chkconfig --del htcachecleanfiposttrans scriptlet (using /bin/sh): #卸载完成执行之后执行的脚本test -f /etc/sysconfig/httpd-disable-posttrans | | /sbin/service httpd condrestart >/dev/null2>&1 | | :
This article from "Plum blossom fragrance from bitter cold" blog, please be sure to keep this source http://ximenfeibing.blog.51cto.com/8809812/1631436
Linux Package Management