Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of package managers rpm and yum

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces in detail the use of the package manager rpm and yum, the sample code in the article is very detailed, and the detailed explanation of the picture and text is easy to learn, which is very suitable for beginners. Interested friends can refer to it.

In the early days, when we installed the program on Linux, we used the source code to install the application, which meant that we had to preprocess, compile, assemble, link and finally generate executable binaries. This operation is too tedious. In order to simplify the installation steps and facilitate the installation and deployment of the program for the majority of users, the program provider compiles and packages the installation files of the relevant programs on a specific system and provides them for download. The package manager is the one that manages these packages.

There are different package managers for different Linux distributions; here are some commonly used package managers

The dpkg tool manages all package files with .deb suffixes in Debian; the most classic rpm package manager is used in Redhat. Rpm is the industry standard of Linux's package manager and is written in Perl language. on this basis, it is rewritten in C language, which improves its running efficiency. Dpkg was first developed by the Debian Linux community. As long as it is derived from Linux distributions Debian, most other Linux distributions use dpkg to manage software, including B2D, Ubuntu and so on. The front-end tools are apt-get.

Here, I will mainly introduce the related functions of the rpm package manager.

First of all, you must be clear about the rpm source code package and the naming rules of the binary package, and be familiar with the information given in it.

Source code package: software_name-VERSION.src.rpm

Binary package: software_name-VERSION- [release]. [os] .arch.rpm

Software_name: software name

VERSION: version number, divided into major version number major, minor version number minor and release version number release

[os]: supported operating system version information, el6,el7,suse11,fedora22...

Arch: the type of hardware platform, i386 and i686, i686, x64, ppcsparc, and noarch.

When making rpm, the producer usually makes both the main package and the secondary package, and there is a dependency between them, that is, a certain part of the program can be installed first before the next installation can be carried out according to the part he depends on, otherwise, the installation cannot be carried out.

Main package:

Software_name-VERSION- [release]. [os]. Arch.rpm

Ancillary feature Pack:

Software_name-function-VERSION- [release]. [os]. Arch.rpm

Rpm command line tool:

① can package compiled programs and package them together.

② can install, uninstall, view, upgrade, verify and manage database functions.

When installing with the rpm package, the rpm program manager automatically generates the program's files, file listings (saving file names and dependencies), and some fixed script contents required by the installer, such as pre-installation scripts preinstall, post-installation scripts

Postinstall, pre-uninstall script preunistall, post-uninstall script postunistall, etc.; you also need to install the rpm database and compare the installed programs to see if the version is the latest; the database path is / var/lib/rpm;. When installing, uninstalling and other operations, it should be carried out under Packets under the CD mount point.

Rpm command:

-v: displays the details of the installation routine

-vv: displays very detailed installation information

Installation:

Rpm {- I |-- install} [install-options] PACKAGE_FILE...

Install-option:

-hmam Murray hash: use 50 # to indicate the installation progress.

-- test: it is not a real installation package, just testing whether it can be completed properly during installation. If it fails, state the reason.

-- nodeps: ignore installation errors due to dependencies; (not recommended)

-- replacefiles: when installing a software package, the files in the package will directly replace the files that were originally installed

-- replacekgs: reinstall without uninstalling the package

-- noscripts: do not run any scripts

-- nopre: do not run pre-installation scripts

-- nopost: do not run post-installation scripts

-- nosignature: do not consider whether the source of the package is legitimate

-- nodigest: regardless of whether the package is complete

Common combination option:-ivh

For example, the installation tree command # is the installation progress of the-h option, and tree-1.6.0-10.el7.x86_64.rpm is the installation routine information of the-v option.

Use-- test for test operation, test the installation to see if it works, and do not carry out substantive installation

Upgrade:

There are two ways to upgrade an installation:

Rpm {- U |-- upgrade} [install-options] PACKAGE_FILE...

If the program is not installed in advance, install the latest version of the program directly, and if the program is already installed, upgrade and install on the basis of the program

Rpm {- F |-- freshen} [install-options] PACKAGE_FILE...

Only low-version packages that have been installed can only be upgraded and installed

Note: in order to ensure the normal operation of the system, it is best not to upgrade the kernel.

The common options are the same as the installation:

-hmam Murray hash: use 50 # to indicate the installation progress.

-- test: it is not a real installation package, just testing whether it can be completed properly during installation. If it fails, state the reason.

-- nodeps: ignore installation errors due to dependencies; (not recommended)

-- replacefiles: when installing a software package, the files in the package will directly replace the files that were originally installed

-- replacekgs: reinstall without uninstalling the package

-- noscripts: do not run any scripts

-- nopre: do not run pre-installation scripts

-- nopost: do not run post-installation scripts

-- nosignature: do not consider whether the source of the package is legitimate

-- nodigest: regardless of whether the package is complete

-- oldpackage: downgrade the installation and replace the new version of the package with the old version

Uninstall:

Rpm {- e |-- erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME (software name).

Common options:

-- allmatches: versions of all packages that match the specified name when uninstalled

-- test: test uninstall

-- nodeps: one column relationship is ignored when uninstalling, and it is not recommended

Example

Uninstall operation is relatively simple, direct command + option + uninstalled software name

Query:

Query is needed before installation, query before uninstallation, query before any operation.

Rpm {- Q |-- query} [select-options] [query-options] (give the package name directly)

Select options:

-amam Murall: query information on all installed packages

Find related software packages for example

-fmam Murray file FILE: find the specified file provided by that package

-- whatprovides CAPABILITY: query which package provides the specified CAPABILITY

Which package provides the example lookup file / bin/chown

-pmam Murray package PACKAGE_FILE (package file name):

Perform query operations on package files that have not yet been installed; package files must be matched with p

[root@localhost wjq] # rpm-qpl / media/guangpan/Packages/tree-1.6.0-10.el7.x86_64.rpm

Query options:

-- changelog: query the changelog of the rpm package

-cmaire: query what configuration information is contained in the specified package

-dmine:: query which document files are in the specified package

Check what document files are in the tree package for example

-imam copyright info: query package related information, including version number, release number, size

Check the relevant information of tree program for example

-lmmam Musi list: list shows which files are generated by the program

Example

-- provides: lists all the CAPABILITY provided by the development package

-Rmaine Methodist: query package dependencies

-- scripts: view the contents of the scripts carried by the package

Verification: used to check whether the file properties generated by the package installation have changed

Rpm {- V |-- verify} [select-options] [verify-options]

Select options is the same as the select options of the query

Common options:

-V: followed by the name of the program, which will be displayed if the file to which the program belongs changes.

Example

-Va: displays all files that may have been modified on the current system

Example

-Vp: followed by the file name, which shows the files that may have been changed in the program

-Vf: followed by a file name, indicating whether a file has been modified.

Corresponding attribute bit description: the attribute will be displayed only after the corresponding attribute is changed.

S file Size differs indicates that the file size has changed

The permissions or types of M Mode differs (includes permissions and file type) files have been modified

5 digest (formerly MD5 sum) differs file content changed

D Device major/minor number mismatch primary device number and secondary device number have changed

L readLink (2) path mismatch path change

U User ownership differs owner has changed.

The group of G Group ownership differs has changed.

The modification time of the T mTime differs file has changed

The capabilities of the P caPabilities differ package have changed

Database management: the database path is / var/lib/rpm. If the data under this path is destroyed, the system cannot know which software is in the system, and the details of those software cannot be displayed.

Rpm database management is mainly divided into two parts: initialization and reconstruction. Initialization, if the database has been installed, the initialization result will remain unchanged. If the database is not installed, the database will be installed. Reconstruction is an overlay installation operation based on the original database.

Rpm {--initdb |-- rebuilddb}-- dbpath / PATH/TO/FILE

-- initdb: initializes the database

-- rebuilddb: rebuild the database

Yum package Manager:

Yum (full name Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora and RedHat as well as SUSE. Based on RPM package management, RPM packages can be downloaded and installed automatically from designated servers, dependencies can be automatically handled, and all dependent software packages can be installed at once without having to download and install them again and again. Yum provides commands to find, install, and delete one, a group, or even all of the software packages, and the commands are concise and easy to remember. Yum is a client-server model, and the server, also known as the software repository, stores many software packages for installation; the client is used to specify the path of the server and the package to drink some necessary control operations.

Main configuration file / etc/yum.conf for yum

This file is generally not modified and only provides the common configuration information of the yum package.

Secondary profile / etc/yum.repos.d/*.repo of yum

Create a text file with the suffix repo in the yum.repos.d directory, and each file can be configured to point to multiple software repositories. When installing or updating, the yum command obtains multiple software repositories by finding the path pointed to by these configuration files, and gets the latest version from these software repositories for installation or update.

The format in the text file created under / etc/yum.repos.d:

[repoid]

Name=

Baseurl=schema://hostname/PATH/TO/REPODATA (hostname can be omitted or not written)

Schema:

Http,ftp,nfs: the network server points to

File: the local server points to

Enabled= {0 | 1}. 0 means to disable this warehouse pointing, 1 means to enable it. If there is no enable statement, the default is startup status.

Gpgcheck= {0 | 1}: 0 means no package authentication; 1 means authentication. If it is 1, you need to specify the public key document required for authentication and use gpgkey statement.

Gpgkey=schema://hostname//PATH/TO/PUBLIC_KEY_FILE package public key, which can be omitted when pointing for the local server

Example

Note: [repoid] is used to isolate different configuration information under the same text file, and all configuration information takes effect from one [] to the next [].

Main profile resolution:

The directory of the cachedir:yum cache, where yum stores downloaded rpm packages and databases, usually / var/cache/yum.

Debuglevel: debug level, 0 ── 10, default is 2

The log file for logfile:yum. The default is / var/log/yum.log.

Exactarch, there are two options 1 and 0, indicating whether to upgrade only packages that are consistent with your installation package cpu. If set to 1, then if you install an i386 rpm, yum will not upgrade with 686 packages.

Gpgchkeck= has two choices of 1 and 0, which represent whether or not to perform a gpg check. if not, it seems to be checked by default.

Custom configuration software repository

1. Create a directory to put the required packages in the directory

two。 Create a warehouse using the createrepo command; generate repodata

3. Create a configuration file about the software repository under / etc/yum.repos.d with the suffix repo

Yum command (this command should be used in the case of networking):

Yum [options] [command] [package...]

Option:

-Q: quiet mode, so that yum does not output any information and does not show the installation process

All interactive yes or no under the-y:yum command is represented by yes

Yum installation:

Yum install: install all

Install package1 [package2] [...]: specify the package installation

Yum uninstall:

Yum remove | erase package1 [package2] [...]

Yum updates:

Update [package1] [package2] [...]: update the updated package

Update-to [package1] [package2] [...]: specifies the update of the destination version number

Yum list [...] Query operation to view the installed, uninstalled but available packages under the current system

View all packages:

Yum list all

View all installed packages:

Yum list installed

Displays all packages that have not been installed but can be installed:

Yum list available

Show recently installed packages:

Yum list recent

Displays all packages that can be upgraded:

Yum list updates

Yum clears the cache:

Clean up local cache information

Clean [packages | metadata | expire-cache | rpmdb | plugins | all]

Clear the software packages in the cache directory

Yum clean packages

Administrative commands for the package group:

Groups [...]

Group installation:

Groupinstall group1 [group2] [...] Equal to groups install

Group updates:

Groupupdate group1 [group2] [...] Equal to groups update

Displays a list of current groups:

Grouplist [hidden] [groupwildcard] [...]

Uninstall the installed group:

Groupremove group1 [group2] [...]

Display group information:

Groupinfo group1 [...]

Match according to keywords, by default, search package name and summary information, fuzzy search

Search string1 [string2] [...]

Yum reinstallation

Reinstall package1 [package2] [...]

Show all dependencies for each package

Deplist package1 [package2] [...]

The above is the package manager rpm and yum usage introduction, detailed use of their own use to know the specific essentials. If you want to know more about it, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report