Linux software installation management — detailed explanation of RPM and yum


1、 Preface

Last article《Linux software installation management — source code installation details》This paper introduces the installation principle of source code package under Linux platform in detail. Although using source code for software compilation can have customized settings, it is not too late for Linux distribution publishers to manage software. After all, not everyone will compile source code. This problem will seriously affect the distribution and promotion of software on Linux platform.

In order to solve the above problems, manufacturers first compile the software required by our users on their system, and then release the compiled and executable software directly to users for installation. Different Linux distributions use different packaging systems. Generally speaking, most distributions belong to two major package management technology camps: Debian’s ” Deb “, and red hat’s” rpm”。 There are some important exceptions, such as Gentoo, Slackware, and foresight, but most will use one of these two basic systems.

Here we will introduce the detailed usage of RPM and Yum of red hat series distribution. If you need to know the package management system of Debian series distribution, you can see my other article:《The of Linux software installation management — dpkg and apt – * detailed explanation》。

2、 RPM

1. Introduction:

Rpm is named “RedHat package manager”, which is called rpm for short. This mechanism was first developed by red hat, and later it is very easy to use. Therefore, many distributors use this mechanism as the management method of software installation, including Fedora, CentOS, SUSE and other well-known developers.

The biggest feature of RPM is that the software to be installed has been compiled and packaged into the installation package of RPM mechanism. The dependent software required for the installation of this software is recorded through the default database inside. When installing on your Linux host, RPM will first query the dependency properties of the Linux host according to the data in the software to see if the software meets the requirements. If it meets the requirements, it will be installed. If not, it will not be installed.

2. Advantages and disadvantages of RPM


1) The software has been compiled and packaged, so it is convenient for transmission and installation, so users can avoid compilation

2) Before installation, the disk and operating system version of the system will be checked to avoid wrong installation

3) The information of the software has been recorded in the database of the Linux host, which is convenient for query, upgrade and uninstall


1) The environment in which the software package is installed must be consistent with or equivalent to the environment at the time of packaging

2) Dependent software must be installed

3) When uninstalling, the lowest software cannot be removed first, otherwise the whole system may be unusable
In order to solve the problem of RPM attribute dependency, the following will also introduce the usage of Yum in detail.

3. Meaning of RPM package naming

Naming format of RPM package:

Software name – version number – release times Suitable for Linux system Hardware platform rpm
For example: ftp-0.17-74 fc27. i686. rpm

be careful:

Full package name: the software package not installed for RPM operation uses the full package name

Package name: the installed software operated by rpm. The software package uses the package name

For example, in the above example, the full name of the package is ftp-0.17-74 fc27. i686. RPM, the package name is FTP.

4. Default path for RPM installation software

/Etc configuration file placement directory

/Usr / bin some executable files

/Usr / lib dynamic link library used by some programs

/Usr / share / doc some basic software manuals and instruction documents

/Usr / share / man page files

5. RPM installation schematic

Linux software installation management -- detailed explanation of RPM and yum

3、 RPM user manual

1. Software installation

If you need to install an EMAC editor, first download an EMAC RPM package from the Internet, such as emacs-25.3-1 fc28. aarch64. rpm。 The simplest installation commands are as follows:

rpm -i emacs-25.3-1.fc28.aarch64.rpm

However, such parameters cannot actually display the progress of installation, so we usually execute the following command:

rpm -ivh package-name

Parameter description (English description in parentheses):

-i: Install means install

-v: Provide more detailed output

-h: The installation progress is displayed in the installation information bar

rpm -ivh emacs-25.3-1.fc28.aarch64.rpm

If you want to install multiple, space them and then connect the RPM package to be installed. At the same time, it also supports installation through the resources of the website.

2. Software upgrade

Parameter description (English description in parentheses):

-U: Upgrade means to update the software. If the software is not available in the system, install it (upgrade package (s))

-F: Update package (s) if already installed

rpm –Uvh  foo-2.0-1.i386.rpm

3. Query mode

When RPM queries, it actually queries the database files in the directory / var / lib / RPM /. In addition, RPM can also query the information in the uninstalled RPM file.

The query syntax of RPM is:

RPM {-q| — Query} [select options] [Query options] common parameter description (English description in parentheses):

-a: All the software installed on this machine is listed in query package

-p: Package: query an (uninstalled) package

-f: File, find out which installed software (query package owning file.) the file belongs to from the file name followed

-i: Display package information, including name, version, and description

-l: List, which lists the complete file name of all files and directories of the software (list file in package)

-c: Configuration, list all setting files of the software (just find the file name under / etc /) (list only configuration files)

-d: Documentation, list all the help documents of the software (list only documentation files)

-R: Required, list capabilities on which this depends

Note: in the query part, all parameters must be preceded by – Q, which is the so-called query.

Use case:

1) Check whether a software is installed on your Linux

rpm -q yum

2) Query all directories and files provided by the software

rpm -ql yum

RPM - QC Yum # only lists all setup files for the software

RPM - QD Yum # only lists all help documents for the software

3) List the relevant data description of GCC software

rpm -qi gcc

4) Find out which software provides / bin / sh

rpm -qf /bin/sh

5) Suppose I download an RPM file named wget-1.19.1-3 fc27. aarc64. RPM, what should I do if I want to know the requirements document of this document?

rpm -qpR wget-1.19.1-3.fc27.aarc64.rpm

4. Uninstall software

When using rpm, you must uninstall from the top to the bottom. Take RP PPPoE as an example. This software is mainly installed according to PPP, so when you want to uninstall PPP, you must uninstall RP PPPoE first!

The delete command is very simple and can be completed through the – e parameter. However, it often happens that the dependency of software attributes leads to the failure of some software in shanwa.


rpm -e gcc

To learn more about how to use rpm, you can consult the man Manual of RPM. Here are just some common operations.

4、 Yum

1. Introduction:

Yum can be regarded as the software of CS architecture. The existence of Yum solves the problem of attribute dependency of RPM.

Yum realizes the functional expansion of RPM package manager by relying on RPM package manager. Therefore, yum cannot run independently of RPM.

2. Features of Yum

1) Multiple repositories can be configured at the same time

2) Concise configuration file (/ etc / yum. CONF)

3) Automatically solve dependency problems encountered when adding or deleting RPM packages

4) Easy to use

5) Maintain consistency with RPM database

3. Yum principle description

The server side first classifies the packages and then stores them in different repository containers; Then, by collecting a large number of dependency data between packages in the database files of RPM, a description file (. XML format) of the corresponding dependency and the local storage location of the required files is generated and stored in the local repodata directory for client access

When cilent installs the software through the yum command, it is found that some dependent packages are missing. The client will find the specified server side according to the local configuration file (/ etc / yum. Repos. D / *. Repo) and obtain the description file xxx from the server side repo directory XML is stored in the local / var / cache / Yum for later reading through XXX The XML file finds the storage location of the dependent packages to be installed on the server side, and then enters the specified repository container in the yum library on the server side to obtain the required packages. After downloading, install them locally.

Linux software installation management -- detailed explanation of RPM and yum

Note: Yum is an online software management tool, so most operations using Yum can be used normally only under the condition of networking.

5、 Configuration file for yum

1. Container description

Although you can use Yum directly after networking, the connection speed will be very slow because you don’t choose the site image of your system well! Therefore, at this time, we need to manually modify the setting document of Yum.

If you are connected to the image site of CentOS(…)After, you will find a pile of links inside. Those links are the containers provided by the yum server, including centosplus, extras, FastTrack, OS, updates and other containers. The best ones are OS (the default software of the system) and updates (software upgrade version).

In the container of Yum server, the most important directory is “repodata”, which is the place where the software dependency data generated after analyzing RPM software is placed. Therefore, when you find the web address of the container, the most important thing is that there must be a directory named “repodata” under the web address, which is the web address of the container.

Take my host as an example: CentOS 7.4.1708

2. Container query

First, you can query the containers used by the directory Yum server.

Using the command Yum repolist all, the query results are as follows:

Linux software installation management -- detailed explanation of RPM and yum

As shown in the figure above, the container is activated only when the rightmost status is enabled,

/etc/yum. repos. D / there will be multiple configuration files (the file name ends with. Repo), and Yum will find them one by one, so the container names in it cannot be repeated.

3. Profile modification

Open the configuration file: VI / etc / yum repos. d/CenOS-Base. Repo, as follows

Linux software installation management -- detailed explanation of RPM and yum

The above is only a screenshot of some containers. The description of the configuration file is as follows:

[base]: represents the name of the container. Brackets must exist. The name inside can be used at will, but there cannot be two identical container names. Otherwise, Yum will not know where to find the container related software list file.

Name: it’s just to explain the meaning of this container. It’s not very important.

Mirrorlist: list the mirror sites that can be used by this container. If you don’t want to use it, you can comment out this line.

Baseurl: This is the most important, because it is followed by the actual URL of the container. Mirrorlist is to find the mirror site by the yum program,
Baseurl is a fixed container URL.

Enable = 1: start the container, and the default value is 1. Close this container and set enable = 0.

Gpgcheck = 1: Specifies whether to check the digital certificate in the RPM file.

Gpgkey: the location of the public key file of the digital certificate. Use the default value.

be careful:

1) Yum will automatically recognize / etc / yum repos. D / table of contents in Repo end file.

2) When we modify the web address of the configuration file without modifying the container name, the local list will be out of sync with the list of Yum server. At this time, we need to manually clear the container data:

Syntax: Yum clean [packages|headers|all]


Packages: delete the downloaded software files

Headers: delete the header of the downloaded software file

All: delete all container data

Example: delete all the downloaded container related data (including the software itself and the list)

yum clean all

6、 Yum user manual

1. Inquiry

Query related commands:

Search: search for an important keyword of a software name or description;

List: lists the names and versions of all the software managed by yum, which is similar to RPM – QA

Info: same as above, but a little similar to RPM – QAI

Provides: search for software from files! Similar to RPM – QF

1) Query the software related to FTP

yum search ftp

2) Query the function of GCC software

yum info gcc

You can query the version number, description information and whether the software has been installed.

3) Lists all the software names provided on the yum server

yum list

4) List the software that can be upgraded on the server at present

yum list updates

5) List the software that provides passwd file

yum provides passwd

6) Find out which software names start with PAM

yum list pam*

2. Installation and upgrade

Related commands:

Install: followed by the software to be installed.

Update: followed by the software to be upgraded. If you want to upgrade the whole system, you can update it directly.

Example: install an Emacs editor software

yum install emacs

Using the parameter – y, when you need to wait for user input, this option will provide a yes response. For example, the above example can be written as: Yum – y install Emacs

4. Unload

Related commands:

Example: uninstall Emacs installed in the above example

yum remove emacs

5. Software group management

Remember when you newly installed CentOS, you can choose the required software? And don’t those software exist by using names such as Gnome / KDE / X window? In fact, this is the software group. The existence of software level is a very useful function for a large number of series of software installations.

Description of relevant commands:

Group list: lists all available groups

Groupinfo: followed by group name, you can know all the group names contained in the group

Group install: install a whole level of software

Group remove: deletes a group

1) Query the available and installed software groups on the current container and local machine

yum grouplist

2) View information about a software group

yum groupinfo GNOME

3) Install desktop environment Gnome

yum groupstall GNOME

To learn more about how to use yum, you can also consult the man Manual of Yum by yourself.

After learning the operation of yum, do you suddenly feel that the software management on Linux has become much simpler. It seems that the RPM you learned earlier is not needed! Even so, yum is based on RPM after all, so you still need to master the knowledge about rpm.


“Brother bird’s Linux private dishes – Basic Learning chapter” brother bird

《The Linux Command Line》William E. Shotts, Jr.