Rpm for linux package management

Source: Internet
Author: User
Tags openldap

Rpm for linux package management
After all, the source code compilation and installation methods of linux programs are cumbersome and difficult to manage after installation. For this reason, linux officially provides a dedicated Package Manager to solve these problems. 1. Package Manager: compile and package the source program into one or a limited number of files, which can be used to manage the installation, query, upgrade, uninstall, and other functions of the Package Manager: ① database, used to record: dependency between program names and version programs functional description of the various file paths and verification code generated by installation ② program composition list: file list installation and uninstallation scripts run when the common Package Manager: Redhat: rpm (redhat package manager), whose package suffix is. rpm, the corresponding front-end tool is yum Debian: dpkg, and its corresponding package suffix is. deb. The rpmbuild tool is required for the preparation of apt-get rpm packages. The preparation process is not described here, the following describes the rpm package management 2. rpm package 2.1 and the rpm package naming format: name-version. -Release. arch. rpm, like httpd-2.2.15-45.el6.centos.x86_64.rpmversion: major. minor. release, same source code release: The release Number of rpm itself. It has nothing to do with the release number of the source code. It is only used to identify revisions made to different rpm packages. The release also contains the OSarch applicable to this package: applicable hardware platforms such as x86: i386, i386, i586, and i686: x86_64: x86_64powerpc: ppcnoarch: depending on the Virtual Machine 2.2, rpm subcontracting mechanism, a program may be very large, in order to facilitate management, rpm package manager package a program into several package MAIN package (core package) based on functional differences: its name is consistent with the source program, such as httpd-2.2.15-45.el6.centos.x86_64.rpm sub package: httpd-devel-2.2.15-45.el6.centos.x86_64.rpm httpd -Tools-2.2.15-45.el6.centos.x86_64.rpm difference: Program x depends on y and z, if x is based on rpm package installation, x depends on y and z core package; if x is based on source code compilation and installation, x depends on the Development Kit 2.3 of y and z, the path to getting the rpm package ① official release of the CD, official site, mirror site mirros.163.com mirrors.sohu.com ② official website of the project: source code, rpm package ③ reliable path for making and Releasing many rpm packages rpmfind.net rpm.pbone.net ④ by third-party organizations or individuals: EPEL, verify the legitimacy of the 2.4 rpm package maintained by Federa. the legitimacy of the rpm package includes source legitimacy and package integrity. The package producer uses a one-way encryption algorithm to extract the signature of the original data, use your own private key to encrypt this signature, and append it to the original data for verification. Prerequisites: there must be a reliable mechanism to obtain the package maker's public key ① use the package maker's public key to decrypt that encrypted signature, Decryption indicates that the source is valid. ② use the same one-way encryption algorithm as the producer to extract data signatures and compare them with the decrypted signatures, if they are the same, the package integrity is normal. 2.5. The rpm package manager uses (I) to verify the validity of the package. We generally need to check the validity of the rpm package before installing it, in particular, packages obtained from unofficial or unofficial sites. Of course, not verifying the validity of the package does not affect the installation of the package. ① import the producer's public key rpm -- import/path/to/key_file. ② If the public key has been imported, the validity of the rpm package is automatically checked during installation. ③ manual check: rpm-K/path/to/pkg_name rpm -- checksig/path/to/pkg_name does not check the package integrity: rpm-K -- nodigest/path/to/pkg_name does not check the package source validity: rpm-K -- nosignature/path/to/pkg_name ④ rpm-qa gpg-pubkey * # display all public keys in the imported gpg format rpm-qi gpg-pubkey-NAME # display key detailed information

[Root @ localhost ~] # Mount/dev/cdrom/media # mount the CD released on the centos official website [root @ localhost ~] # Ls/media # centos disc comes with a lot of rpm Packages, located in the Packages directory CentOS_BuildTag EULA imagesPackagesrepodata RPM-GPG-KEY-CentOS-Debug-6 RPM-GPG-KEY-CentOS-Testing-6EFI GPL isolinux RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-6 TRANS. TBL [root @ localhost ~] # Cd/media/Packages/[root @ localhost Packages] # ls... libreoffice-langpack-et-4.0.4.2-9.el6.x86_64.rpm zlib-devel-1.2.3-29.el6.x86_64.rpmlibreoffice-langpack-eu-4.0.4.2-9.el6.x86_64.rpm zsh-4.3.10-7.el6.x86_64.rpm [root @ localhost Packages] # rpm-ivh -- test samba-3.6.9-164.el6.x86_64.rpm # test installation warning: samba-3.6.9-164.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY # warning: without the public key, you cannot verify the validity of the package Preparing... ######################################## ### [100%] [root @ localhost Packages] # rpm -- import .. /RPM-GPG-KEY-CentOS-6 # import the Public Key provided in the CD [root @ localhost Packages] # rpm-ivh -- test samba-3.6.9-164.el6.x86_64.rpm # You can see that the warning information has been removed and verified through Preparing... ######################################## ### [100%] [root @ localhost Packages] # rpm-K samba-3.6.9-164.el6.x86_64.rpm # You can also manually check the samba-3.6.9-164.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK [root @ localhost Packages] # rpm-qa gpg-pubkey * # view all imported Public Key gpg-pubkey-c105b9de-4e0fd3a3 [root @ localhost Packages] # rpm-qi gpg-pubkey-c105b9de-4e0fd3a3 # view specified public key name: gpg-pubkey Relocations: (not relocatable) Version: c105b9de Vendor: (none) Release: 4e0fd3a3Build Date: Wed 28 Oct 2015 08:31:40 PM CSTInstall Date: Wed 28 Oct 2015 08:31:40 PM CSTBuild Host: localhostGroup: Public Keys Source RPM: (none) Size: 0 License: pubkeySignature: (none) Summary: gpg (CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>) description: ----- begin pgp public key block ----- Version: rpm-4.8.0 (NSS-3) blocks...

 

(Ii) Installation Package rpm-I [option]/path/to/package_file common options:-I: install-h: the hash code is displayed during installation to indicate the installation progress-v: show the execution process-vv: Detailed display of the execution process -- test: Only for testing, not really installed -- nodeps: Ignore dependency -- replacepkgs: reinstall. If the original configuration file is modified, the new configuration file is renamed to X instead of being replaced. common rpmnew combination options:-ivh if it depends on other packages: ① solve the dependency; ② use the -- nodeps option to ignore the dependency, which can be installed but may not run.
[Root @ localhost Packages] # rpm-ivh samba-3.6.9-164.el6.x86_64.rpm Preparing... ######################################## ### [100%] 1: samba ####################################### #### [100%] [root @ localhost Packages] # rpm-ivh -- test mysql-5.1.71-1.el6.x86_64.rpm error: failed dependencies: the system prompts you to resolve the dependency libmysqlclient first. so.16 () (64bit) is needed by mysql-5.1.71-1.el6.x86_64libmysqlclient.so.16 (libmysqlclient_16) (64bit) is needed by mysql-5.1.71-1.el6.x86_64libmysqlclient_r.so.16 () (64bit) is needed by mysql-5.1.71-1.el6.x86_64libmysqlclient_r.so.16 (libmysqlclient_16) (64bit) is needed by the mysql-5.1.71-1.el6.x86_64mysql-libs = 5.1.71-1. el6 is needed by mysql-5.1.71-1.el6.x86_64 [root @ localhost Packages] # rpm-ivh mysql-libs-5.1.71-1.el6.x86_64.rpm # Install the dependent package Preparing... ######################################## ### [100%] 1: mysql-libs ##################################### ###### [100%] [root @ localhost Packages] # rpm-ivh mysql-5.1.71-1.el6.x86_64.rpmPreparing... ######################################## ### [100%] 1: mysql ####################################### #### [100%]

 

(3) uninstall the package rpm-e [option] pkg_name common options:-e: erase-v,-vv, -- test, -- nodeps if it is dependent on other packages: ① unmount all packages dependent on this package ② ignore the dependency and unmount the package, but other packages may fail to use normally. If the package configuration file is modified, this file will be renamed (X. rpmsave) and retain
[Root @ localhost Packages] # rpm-e mysql-libs # uninstall the specified package error: Failed dependencies: # The system prompts that the package is dependent on the mysql package and Cannot uninstall libmysqlclient. so.16 () (64bit) is needed by (installed) mysql-5.1.71-1.el6.x86_64libmysqlclient.so.16 (libmysqlclient_16) (64bit) is needed by (installed) mysql-5.1.71-1.el6.x86_64libmysqlclient_r.so.16 () (64bit) is needed by (installed) mysql-5.1.71-1.el6.x86_64libmysqlclient_r.so.16 (libmysqlclient_16) (64bit) is needed by (installed) mysql-5.1.71-1.el6.x86_64mysql-libs = 5.1.71-1. el6 is needed by (installed) mysql-5.1.71-1.el6.x86_64 [root @ localhost Packages] # rpm-e -- nodeps mysql-libs # ignore dependency force uninstall [root @ localhost Packages] # mysql # You Can See That mysql has been unable to use mysql: error while loading shared libraries: libmysqlclient. so.16: cannot open shared object file: no such file or directory [root @ localhost Packages] # vim/etc/samba/smbusers [root @ localhost Packages] # rpm-e samba # uninstall sambawarning: /etc/samba/smbusers saved as/etc/samba/smbusers. rpmsave # You can see that the modified configuration file is retained after the program is uninstalled.

 

(Iv) upgrade package: the new version replaces the old version rpm-U/-F [option]/path/to/package_file. Common options:-U: upgrade or installation. Install the new version-F: Pure upgrade regardless of the old version. A new version is installed only when an old version is available. If no version is available, -- force: force upgrade will not be installed. This may cause programs dependent on this package to fail to run normally-v.-h commonly used combination options:-Uvh, -fvl Note: You should not upgrade the kernel. You should install the new kernel directly. The system supports coexistence of multiple kernels. If there is any compatibility problem with the new kernel, you can use it back to the old kernel.
[Root @ localhost ~] # Rpm-q zshpackage zsh is not installed # The zsh is not installed [root @ localhost ~] # Rpm-fvl/media/Packages/zsh-4.3.10-7.el6.x86_64.rpm # No old version, do not install [root @ localhost ~] # Rpm-Uvh/media/Packages/zsh-4.3.10-7.el6.x86_64.rpm # install the new version Preparing no matter whether there is any older version... ######################################## ### [100%] 1: zsh ####################################### #### [100%] [root @ localhost ~] # Rpm-q mysqlmysql-5.1.71-1.el6.x86_64 [root @ localhost ~] # Rpm-fvl mysql-5.1.73-5.el6_6.x86_64.rpm # install the new version of mysqlerror: Failed dependencies: prompt to depend on the new version of mysql-libs package mysql-libs = 5.1.73-5. el6_6 is needed by mysql-5.1.73-5.el6_6.x86_64 [root @ localhost ~] # Rpm-fvl mysql-libs-5.1.73-5.el6_6.x86_64.rpm error: Failed dependencies: mysql-libs = 5.1.71-1. el6 is needed by (installed) mysql-5.1.71-1.el6.x86_64 # Here there is a problem: to upgrade the mysql package, you need to first upgrade the mysql-libs package on which it depends, while the mysql-libs package cannot be upgraded, because it is dependent on the existing mysql package, you can only uninstall [root @ localhost ~] # Rpm-e -- nodeps mysql-libs [root @ localhost ~] # Rpm-ivh mysql-libs-5.1.73-5.el6_6.x86_64.rpm Preparing... ######################################## ### [100%] 1: mysql-libs ##################################### ###### [1, 100%] [root @ localhost ~] # Rpm-Fvh mysql-5.1.73-5.el6_6.x86_64.rpm Preparing... ######################################## ### [100%] 1: mysql ####################################### #### [100%] [root @ localhost ~] # Rpm-q mysqlmysql-5.1.73-5.el6_6.x86_64 # upgraded to new version

 

(V) query operation rpm-q [option] [pkg_name] common query operation: ① query whether a package is installed: rpm-q pkg_name ② query all installed packages: rpm-qa can be used together with the grep command to query the packages that conform to the specified paradigm: rpm-qa | grep 'pattern' ③ query the Package Description: rpm-qi pkg_name ④ query the files generated by a package: rpm-ql pkg_name query the configuration files generated by a package: rpm-qc pkg_name query the help files generated by a package: rpm-qd pkg_name query package-related scripts: rpm-q -- scripts pkg_name scripts have four types: preinstall: Pre-installation script postinstall: Post-installation script preuninstall: Pre-uninstall script postuninstall: after uninstalling the package, run script ⑤ to check which package is installed and generated for a file: rpm-qf/path/to/somefile 6 to query uninstalled packages: rpm [option]/path/to/pkg_file. Available combinations include-qpi,-qpl,-qpc, and-qpd.
[Root @ localhost Packages] # rpm-q samba # query whether samba has installed samba-3.6.9-164.el6.x86_64 [root @ localhost Packages] # rpm-qa # query all installed package pulseaudio-module-gconf-0.9.21-14.el6_3.x86_64db4-devel-4.7.25-18.el6_4.x86_64libxklavier-4.0-9.el6.x86_64... [root @ localhost Packages] # rpm-qa | grep 'mysql' mysql-libs-5.1.71-1.el6.x86_64mysql-5.1.71-1.el6.x86_64 [root @ localhost Packages] # rpm-ql samba # view what files are generated by the samba package/etc/ logrotate. d/samba/etc/openldap/schema/samba. schema/etc/pam. d/samba/etc/rc. d/init. d/nmb/etc/rc. d/init. d/smb/etc/samba/smbusers/usr/bin/eventlogadm/usr/bin/mksmbpasswd. sh/usr/bin/smbstatus/usr/lib64/samba/auth... [root @ localhost Packages] # rpm-qc samba # view the configuration files generated by the samba package/etc/logrotate. d/samba/etc/pam. d/samba/etc/samba/smbusers [root @ localhost Packages] # rpm-qd samba # view the help files generated by the samba package/usr/share/doc/samba-3.6.9/ LDAP/README... /usr/share/man/man7/samba.7.gz... [root @ localhost Packages] # rpm-qf/etc/openldap/schema # query which package of the specified file is installed to generate the samba-3.6.9-164.el6.x86_64 [root @ localhost Packages] # rpm-qpi httpd-2.2.15-29.el6.centos.x86_64.rpm # Install httpd view the detailed information Name before the package: httpdRelocations: (not relocatable) Version: 2.2.15Vendor: CentOS

 

(6) Check package: used to check whether the file attributes generated by package installation have changed. rpm-V pkg_name [root @ localhost ~] # Vim/etc/httpd/conf/httpd. conf [root @ localhost ~] # Rpm-V httpds.5 .... t. c/etc/httpd/conf/httpd. conf # we modified the httpd configuration file. We can see that its size, MD5 verification code, and modification time have all changed. For other attributes that do not change, see "s.5 .... t. ", rpm uses seven field bits to indicate the changing states of the seven different attributes of the file. These seven attributes are: S file Size differs # Size M Mode differs (partition des permissions and file type) # permission 5 digest (formerly MD5 sum) differs # MD5 verification code D Device major/minor number mismatch # primary and secondary Device numbers of the Device file L readLink (2) path mismatchU User ownership differs # owner G Group ownership di Ffers # group T mTime differs # modification time P caPabilities differ if the attribute of the corresponding field is changed, it is displayed as the corresponding letter identifier; if there is no change, it is displayed 【.] (vii) re-build the database of the rpm package manager ① database directory of the rpm package manager:/var/lib/rpm ② rpm -- initdb: initialization. If there is no database in advance, a new one will be created. If there is a database, no rpm -- rebuilddb will be created: re-built. Direct reconstruction, covering the original database
[Root @ localhost ~] # Ls/var/lib/logs _ db.001 _ db.003 Alibaba Group NamePackages Provideversion Requirename Sha1header logs _ db.002 _ db.004 Filedigests Installtid implements Providename Pubkeys Requireversion Sigmd5 [root @ localhost ~ # Rpm -- initdb # If the database already exists, [root @ localhost ~] will not be created. # Rpm -- rebuilddb [root @ localhost ~] # Ls/var/lib/rpmBasenames Dirnames Group NamePackages Provideversion Requirename Sha1header TriggernameConflictname Filedigests Installtid Obsoletename Providename Pubkeys Requireversion

 


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.