RPM (RedHat Package Manager)

Source: Internet
Author: User
Tags egrep

Rpm(RedHat Package Manager)

The RPM Installation Package Manager, developed as RedHat, is used to install and manage downloaded packages on the Internet or CD. It is very useful. In centos, it usually generates files ending with. rpm.

These packages generally consist of the following four parts:

Part1, some programs in binary format (this refers to the compilation completed)

In centos5 and 6 environments, they are usually in/bin/sbin/usr/bin/usr/sbin/usr/local/bin/usr/local/sbin directories, some third-party binary applications are also installed under/OPT. In fact, for RPM package management, we can also create a directory by ourselves, for example, in/usr/local/the name of the program you want to install/bin or sbin

Part2, library file! (These library files cannot be run directly. They can only be called by other programs to contribute)

These library files usually end with the. So file in Linux. Library files can be compiled in two ways.

1. Static compiled library files. After compilation, all code and functions are embedded into the program.

2. dynamically compiled library files. These dynamic linked libraries are the libraries loaded when the program is running.

For example, in centos, they are in/lib64 (I am a 64-bit host) for a 32-bit host, it is/lib or/usr/lib64/usr/local/lib64/usr/local/the name of the program to be installed/lib64

Part3, configuration file

These files usually record the configuration information of the RPM package. In the centos environment, they are usually in the/etc or/usr/local/Name of the program you want to install/etc or/Conf

Part4, Help File

These help files record the help information of the RPM program, which is usually in/usr/share/man or/usr/local/share/Man In The centos environment.

Here is a command to view the database dependency of a command.

LDD

LDD [Option]... file...

There are multiple options, and several files can be followed. For example

[[Email protected] lib64] # LDD/bin/ls/bin/grep
/Bin/LS:
Linux-vdso.so.1=> (0x00007fff907ff000)
Libselinux. so.1 =>/lib64/libselinux. so.1 (0x0000003842a00000)
Librt. so.1 =>/lib64/librt. so.1 (0x0000003841a00000)
Libcap. so.2 =>/lib64/libcap. so.2 (0x0000003844a00000)
Libacl. so.1 =>/lib64/libacl. so.1 (0x000000384be00000)
Libc. so.6 =>/lib64/libc. so.6 (0x0000003841200000)
Libdl. so.2 =>/lib64/libdl. so.2 (0x0000003840e00000)
/Lib64/ld-linux-x86-64.so.2 (0x0000003840a000)
Libpthread. so.0 =>/lib64/libpthread. so.0 (0x0000003841600000)
Libattr. so.1 =>/lib64/libattr. so.1 (0x0000003851200000)
/Bin/grep:
Linux-vdso.so.1=> (0x00007fff12308000)
Libpcre. so.0 =>/lib64/libpcre. so.0 (0x0000003474000000)
Libc. so.6 =>/lib64/libc. so.6 (0x0000003841200000)
/Lib64/ld-linux-x86-64.so.2 (0x0000003840a000)

We found that there is no linux-vdso.so.1 library file here, it does not show any link to the library file behind, but almost any command will appear It, it is actually a library file that links other library files. You can use this command to view the dependencies between different library files.

The program in the RPM package is dependent, and the dependency can only be eliminated by yum, its front-end tool. The so-called dependency is when you install. remind you to install B. rpm is enough. If you want to install a small program of several hundred kb, you will find that it is not as simple as you want. You need to install this one. After the installation is completed, dozens of MB are found.

Next let's take a look at what the RPM package looks like

Prerequisites: I mounted the system disk to/Media/CDROM IN THE centos6.5 environment.


[[Email protected] CDROM] # ll
Total 682

-R -- 2 root Root 14 Nov 29 2013 centos_buildtag
Dr-XR-x 3 Root 2048 Nov 29 2013 EFI
-R -- 2 root Root 212 Nov 28 2013 EULA
-R -- 2 root Root 18009 Nov 28 2013 GPL
Dr-XR-x 3 Root 2048 Nov 29 2013 Images
Dr-XR-x 2 root Root 2048 Nov 29 2013 isolinux
Dr-XR-x 2 root Root 655360 Nov 29 2013 packages
-R -- 2 root Root 1354 Nov 28 2013 RELEASE-NOTES-en-US.html
Dr-XR-x 2 root Root 4096 Nov 29 2013 repodata
-R -- 2 root Root 1706 Nov 28 2013 RPM-GPG-KEY-CentOS-6
-R -- 2 root Root 1730 Nov 28 2013 RPM-GPG-KEY-CentOS-Debug-6
-R -- 2 root Root 1730 Nov 28 2013 RPM-GPG-KEY-CentOS-Security-6
-R -- 2 root Root 1734 Nov 28 2013 RPM-GPG-KEY-CentOS-Testing-6
-R -- 1 Root 3380 Nov 29 2013 trans. TBL

We mainly look at the installation packages directory marked with red, which stores the installation packages required for system program installation. Let's CD it to this directory and view it.


-R -- 2 root Root 52300 Mar 22 2013 qt-sqlite-4.6.2-26.el6_4.i686.rpm
-R -- 2 root Root 52192 Mar 22 2013 qt-sqlite-4.6.2-26.el6_4.x86_64.rpm
-R -- 2 root Root 12866892 Mar 22 2013 qt-x11-4.6.2-26.el6_4.i686.rpm
-R -- 2 root Root 12704556 Mar 22 2013 qt-x11-4.6.2-26.el6_4.x86_64.rpm
-R -- 2 root Root 1109204 Sep 13 2012 quagga-0.99.15-7.el6_3.2.x86_64.rpm
-R -- 2 root Root 205420 Nov 25 2013 quota-3.17-20.el6.x86_64.rpm
-R -- 2 root Root 76828 Jul 3 2011 radvd-1.6-1.el6.x86_64.rpm
-R -- 2 root Root 178316 Jul 3 2011 rasqal-0.9.15-6.1.el6.i686.rpm
-R -- 2 root Root 176872 Jul 3 2011 rasqal-0.9.15-6.1.el6.x86_64.rpm
-R -- 2 root Root 177564 Jul 3 2011 rcs-5.7-37.el6.x86_64.rpm
-R -- 2 root Root 19052 Jul 3 2011 rdate-1.4-16.el6.x86_64.rpm

........

A lot will be listed below. The space here is limited and will not be listed one by one

Here is an example of an installation package.

For example, this radvd-1.6-1.el6.x86_64.rpm

The composition format is radvd is the package name, 1.6 is the release number Of The radvd source code, and-1 is the release number of the RPM package of radvd. Later el6 refers to RHEL, short for this industry version. El6 is the release number of series 6.x under RHEL. X86_64. It refers to the x86_64 hardware platform. Of course, some packages will show noarch, indicating that there is no hardware platform that requires support from virtual machines.

There are many ways to get the RPM package. Here I use the CD image of the release version. Below are several common approaches for your reference:

1. some well-known site servers in China

Http://mirrors.163.com
Http://mirrors.sohu.com

2. The official website of this package will contribute the RPM package or the RPM package written in the source code.

3. RPM packages published by many third-party organizations or individuals

Like http://rpmfind.net
Http://rpm.pbone.net

When there are so many rpm packages on the Internet, it is inevitable that there will be poor quality. In order to avoid some malicious tampering with the legitimacy and integrity of rpm. We recommend that you verify the image on your CD.

-R -- 2 root Root 1706 Nov 28 2013 RPM-GPG-KEY-CentOS-6
-R -- 2 root Root 1730 Nov 28 2013 RPM-GPG-KEY-CentOS-Debug-6
-R -- 2 root Root 1730 Nov 28 2013 RPM-GPG-KEY-CentOS-Security-6
-R -- 2 root Root 1734 Nov 28 2013 RPM-GPG-KEY-CentOS-Testing-6
-R -- 1 Root 3380 Nov 29 2013 trans. TBL
[[Email protected] CDROM] # pwd
/Media/CDROM

Here the red is called RPM-GPG-KEY-CentOS-6 is the disc's public key. Generally, the package producer uses one-way encryption to extract the data signature and then uses its own private key to encrypt the verification code.


The following describes the common steps for RPM packages:

Installation Steps

Take the above RPM package as an example.

We use rpm-I (for example, install)

-V displays detailed installation information

-VV: displays more detailed installation information.

-Vvv: displays more detailed installation information.

-H uses the hash format # To display the 2% installation symbol.

Here, you can find an installation package to perform an experiment.

[[Email protected] packages] # rpm-IVH yelp-2.28.1-17.el6_3.x86_64.rpm
Preparing... ######################################## ### [100%]
Package yelp-2.28.1-17.el6_3.x86_64 is already installed

It tells us that the Yelp package has been installed.

Select another

[[Email protected] packages] # rpm-IVH wsdl4j-1.5.2-7.8.el6.noarch.rpm
Preparing... ######################################## ### [100%]
1: wsdl4j ####################################### #### [100%]

Show that 100% is installed

RPM package installation format: rpm-IV (VV | vvv) h package name (provided that the path must be in the installation package directory)

If we only test the installation, we can add the -- test option, for example

[[Email protected] packages] # rpm-IVH -- Test zsh-4.3.10-7.el6.x86_64.rpm
Preparing... ######################################## ### [100%]
[[Email protected] packages] # zsh
-Bash: zsh: Command not found

Here we just installed the plug-in, but we still cannot use the zsh command.

The complexity of the package causes us a headache. What should we do if we want to reinstall it?

Use the rpm-I -- replacepkgs package name (the path must be in the installation package directory)

[[Email protected] packages] # rpm-I -- replacepkgs zsh-4.3.10-7.el6.x86_64.rpm
[[Email protected] packages] # zsh
[[Email protected]/Media/CDROM/packages # echo $?
0

Shell has become zsh!

Note that when I use rpm-QL zsh to view the file generated by it, there is a file named/etc/zprofile. We will edit it.

#
#/Etc/zprofile and ~ /. Zprofile are run for login shells
#

Path = "$ path: $ home/bin"
Export path

_ Src_etc_profile ()
{
# Make/etc/profile happier, and have possible ~ /. Zshenv options like
# Nomatch ignored.
#
Emulate-l KSh

# Source profile
If [-F/etc/profile]; then
Source/etc/profile
Fi
}
_ Src_etc_profile

Unset-F _ src_etc_profile
# Cool!

At the end of the line, we edit a comment line called cool! Save and exit. Let's reinstall zsh.

[[Email protected] packages] # rpm-IVH -- replacepkgs zsh-4.3.10-7.el6.x86_64.rpm
Preparing... ######################################## ### [100%]
1: zsh ####################################### #### [100%]

Let's look at [[email protected] packages] # Vim/etc/zprofile

Unset-F _ src_etc_profile
# Cool!

Cool information still exists at the end of the line! Why? Reinstallation may retain modifications to the original configuration file.


Uninstall procedure

Let's uninstall an installed package

We can use the rpm-E (erase) package name.

[[Email protected] packages] # rpm-e zsh
[[Email protected] packages] # echo $?
0

Here we have uninstalled zsh. If we want to use zsh, it is unlikely

[[Email protected] packages] # zsh
-Bash: zsh: Command not found

Remind me again, proceed with caution when uninstalling !!

Because the RPM package has dependencies between programs. If we want to ignore the dependencies, we will use the -- nodeps option (not recommended, which may cause some associated programs to fail to run normally)

For the above zsh, uninstall it again ,!!! Warning found

[[Email protected] packages] # rpm-e zsh
Warning:/etc/zprofile saved as/etc/zprofile. rpmsave

Remind you that the configuration file has been modified, and we will not directly uninstall your configuration file, but save it as a new file of. rpmsave. The file content is not modified.

Upgrade procedure

Rpm-uvh/-fvl package name (the path must be under the installation package directory)

-- Force update

Query procedure

At any time, we believe that queries are extremely useful.

1. check whether a package is installed.

Rpm-Q package name

Here is an example:

[[Email protected] packages] #Rpm-Q zsh-4.3.10-7.el6.x86_64.rpm
Package zsh-4.3.10-7.el6.x86_64.rpm Is Not Installed
[[Email protected] packages] #Rpm-Q grep
Grep-2.6.3-4.el6.x86_64

You have found that zsh has been deleted and not installed is displayed, while grep shows the complete program name, because grep is directly installed when centos is installed on the virtual machine.

2. How do I query the packages we have installed?

When rpm-Qa is used (a indicates all), many packages have been installed.

This experiment will basically be flushed, and the landlord is very lazy and will not show it. However, if we want to query a certain item, we can combine the grep command to capture it, for example:

[[Email protected] packages] # rpm-Qa | grep "find"
Findutils-4.4.2-6.el6.x86_64

3. query the description of a package.

We use the rpm-Qi package name (. rpm is not required)

For example: [[email protected] packages] # rpm-Qi grep (enter grep here)
Name: grep relocations: (not relocatable)
Version: 2.6.3 vendor: centos
Release: 4. el6 build Date: Tue 25 jun 2013 10:52:30 pm CST
Install Date: Sat 26 Jul 2014 01:42:17 pm CST build host: c6b8.bsys.dev.centos.org
GROUP: Applications/text source RPM: grep-2.6.3-4.el6.src.rpm
Size: 803774 license: gplv3 +
Signature: RSA/sha1, wed 26 Jun 2013 10:15:56 am Cst, key ID 0946fca2c105b9de
Packager: centos buildsystem URL: http://www.gnu.org/software/grep/
Summary: pattern matching utilities
Description:
The GNU versions of commonly used grep utilities. grep searches through
Textual input for lines which contain a match to a specified pattern and then
Prints the Matching lines. GNU's grep utilities include grep, egrep and fgrep.

GNU grep is needed by using scripts, so it shall be installed on every system.


4. Let's query the files generated by a package.

Rpm-QL package name

For example: [[email protected] packages] # rpm-QL grep
/Bin/egrep
/Bin/fgrep
/Bin/grep
/Usr/share/doc/grep-2.6.3
/Usr/share/doc/grep-2.6.3/ABOUT-NLS
/Usr/share/doc/grep-2.6.3/authors
/Usr/share/doc/grep-2.6.3/readme
/Usr/share/doc/grep-2.6.3/Thanks
/Usr/share/doc/grep-2.6.3/todo

... There are many more. I will not repeat them here.

If you only want to view the configuration files, help files, or scripts generated.

Rpm-QC package name configuration file information

[[Email protected] packages] # rpm-QC zsh
/Etc/skel/. zshrc
/Etc/zlogin
/Etc/zlogout
/Etc/zprofile
/Etc/zshenv
/Etc/zshrc and above are all the configuration file information generated by zsh.

Rpm-Qd package name Help File Information

[[Email protected] packages] # rpm-Qd grep
/Usr/share/doc/grep-2.6.3/ABOUT-NLS
/Usr/share/doc/grep-2.6.3/copying
/Usr/share/doc/grep-2.6.3/readme
/Usr/share/doc/grep-2.6.3/Thanks
/Usr/share/doc/grep-2.6.3/todo
/Usr/share/INFO/grep.info.gz
/Usr/share/man/Man1/egrep.1.gz
/Usr/share/man/Man1/fgrep.1.gz
/Usr/share/man/Man1/grep.1.gz shows that there are many help files for grep.

Run rpm-Q -- scripts to view the script generated by the program file.

Query which package can be used to install a file

Rpm-QF file name such as/bin/ls

# Rpm-qf/bin/ls
Coreutils-8.4-31.el6.x86_64

To view uninstalled packages, add-P to the preceding options.

For example, rpm-QPI is a package name that has not been installed (make sure it is available in the package directory or link)

Run the rpm-qpl/C/D command to view the package generation files, configuration files, and help files that have not been installed.


Rpm is an important tool for linux package manager. The above statement is helpful to readers. Of course, the author will check it in time and share the RPM front-end tool Yum with you later!

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.