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

Package Management of CentOS system-rpm, yum and compilation

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

I. package Manager

1. Operation of the software

2. Package management

Package the compiled files into one or a limited number of files, which can be used to realize convenient program management such as installation, uninstallation, upgrade, query, verification and so on. The commonly used program managers in centos are rpm and yum

2. RPM of the package manager

1. What is rpm

RPM is the abbreviation of RPM Package Manager (RPM package Manager). Although the file format name is marked with the logo of RedHat, its original design concept is open. RPM package Manager (RPM) is a powerful command line-driven package management system capable of installing, uninstalling, verifying, querying, and updating computer software packages. Each package includes archived files along with package and its version information, description, etc. There is also a library, API, that allows senior developers to manage

2. Components of the program

Components of the program:

Before compilation: source code

Compile the file:

Binary program

Library file

Configuration file

Help files (manuals, documents)

Binary programs: / bin, / sbin, / usr/bin, / usr/sbin, / usr/local/bin, / usr/local/sbin, / opt/bin, / opt/sbin

Library file: / lib, / lib64, / usr/lib, / usr/lib64, / usr/local/lib, / usr/local/lib64

Configuration file: / etc, / etc/DIR, / usr/local/ {etc,conf}

Help file: / usr/share/man, / usr/share/doc, / usr/local/share/man

Note: some special applications may place executable files in the libexec directory

3. Rpm package naming format:

4. Subcontracting mechanism

Imagine a scenario where testapp has 30 functions, of which 10 are commonly used, 6 are commonly used, and the remaining 14 are rarely used; so rpm package makers will make each function of a program into a rpm package, and they all rely on the main package.

For example:

Core package, main package: the name is the same as the original project name

Bash-4.3.2-2.centos6.x86_64.rpm

Subpackage (subpackage): the command provides the functional composition of appending the file in the branch package to the name of the source project.

Bash-devel-4.3.2-2.centos6.x86_64.rpm

The acquisition path of the package:

1. The distribution CD image of the system or the official site (or site image server)

Mount the CD:

Mount-r / dev/cdrom / media/cdrom

Official site, mirror 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

Suggestion: verify its legality before installation

Legal source

Integrity of the package

Third, the application of rpm

3.1 installation

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

-I installation

-v displays details, which can be superimposed to view more details, such as-vv,-vvv

-h shows progress, using 50 # as progress bar

We usually use a combination of-ivh to install RPM packages

-- nodeps cancels dependency

-- replacepkgs reinstallation

-- test tests the installation instead of the actual installation

For example: [root@localhost] # rpm-ivh package.rpm

3.2 upgrade

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

Upgrade the installation if you have an older version of the package; if not, install it directly

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

Upgrade the installation if there is an older version of the package; if not, terminate

We usually use a combination of-Uvh and-Fvh to install the RPM package

[install-options]

-- oldpackage downgrade installation

-- force ignores conflicts and enforces

Note:

Do not upgrade the kernel package; linux supports the coexistence of multiple versions of the kernel, so new versions of the kernel can be installed directly

If the configuration file of the original package has been changed after installation, when upgrading, the new version of the file will not directly overwrite the old version of the file, but will rename the new version of the file (with the suffix .rpmnew).

For example: [root@localhost] # rpm-Uvh package.rpm

3.3. Uninstall

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

-- nodeps ignores dependencies

-- test uninstall test

For example: [root@localhost] # rpm-ev package123

3.4. Uninstall query

Rpm {- Q |-- query} [select-options] [query-options]

[select-options]

1. Query whether the package is installed

Rpm-Q PACKAGE_NAME...

2. Query all installed packages

Rpm-qa

3. Query which package installed and generated a file

Rpm-qf / path/to/somefile

4. Query information about packages that have not yet been installed

Rpm-qp PACKAGE_FILE

[query-options]

1. Query the brief description information of a package

Rpm-qi PACKAGE_NAME

2. Query the list of all files generated after a package is installed

Rpm-ql PACKAGE_NAME

3. Query the list of all configuration files generated after a package is installed

Rpm-qc PACKAGE_NAME

4. Query the list of all help files generated after a package is installed

Rpm-qd PACKAGE_NAME

5. Query the changelog list information that changes with version when a rpm package is made.

Rpm-Q-- changelog PACKAGE_NAME

6. Query the capabilities provided by a package

Rpm-Q-- provides PACKAGE_NAME

7. Query the capabilities on which a package depends

Rpm-Q-- requires PACKAGE_NAME

8. Query the script when a package is installed and uninstalled

Rpm-Q-- scripts

Additional: there are four types of scripts to install and uninstall:

Preinstall: script executed before installation

Postinstall: script executed after installation

Preuninstall: script executed before uninstallation

Postuninstall: script executed after uninstallation

3.5 check

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

Common usage: rpm-V PACKAGE_NAME

After the file is changed, the check will have the following information prompt:

5: the MD5 check value of the file

S: file size

L: linked fil

T: time when the file was created

D: device fil

U: the user of the fil

G: the user group of the file

M: permissions for the file

3.6 Verification of the legitimacy and integrity of the source of the package

Rpm-- import PUBKEY...

Import key

Rpm {- K |-- checksig} [--nosignature] [--nodigest] PACKAGE_FILE...

Authentication key

-- nosignature: do not check the validity of the source

-- nodigest: integrity is not checked

3.7.Public database: / var/lib/rpm

Rebuild the database

Rpm {--initdb |-- rebuilddb}

Initialize:-- initdb

If the data does not exist in advance, it will be new; otherwise, no action will be performed

Restructure:-- rebuilddb

Regardless of whether the database already exists or not, the existing database will be rebuilt and overwritten directly

4. Yum of the package manager

1. Yum introduction

Yum: Yellow dog Updater,Modified, the main function is to add / delete / update RPM packages more conveniently, it can automatically solve the problem of package dependence, and it is easy to manage the update problems of a large number of systems

2. Configure yum repository

Yum Warehouse profile:

Point to the location of the warehouse and various configuration information; each yum customer can have multiple yum repositories available

The main configuration files are:

/ etc/yum.conf

/ etc/yum.repos.d/*.repo

Advanced usage of yum client configuration:

(1) if you have multiple yum repositories and want to give priority to use, you can add a line of cost to the configuration file to define the usage expense value of the warehouse. The default value is 1000. The lower the value, the higher the priority.

For example: cost=400

(2) variables can be used when specifying paths in baseurl

For example: http://mirrors.sohu.com/centos/$releasever/os/$basearch

(3) you can use the mirrorlist instruction to replace baseurl

Point to a URL, which is a text file that holds a large list of mirror servers. When you use the yum repository, users will get this list file, and then use the fastestmirror plug-in to determine which image is the fastest access server and use it as the baseurl for this visit.

3. The application of yum

3.1 installation

Yum install PACKAGE_NAME...

-y: the automatic answer is yes

If you need to install the specified version of the program:

Yum install PACKAGE-VERSION...

Reinstall the specified package:

Yum reinstall PACKAGE_NAME...

3.2 upgrade

Yum update PACKAGE_NAME

If more than one version of the upgrade package is available and you only expect to upgrade to the specified version:

Yum update PACKAGE-VERSION

Downgrade:

Yum downgrade PACKAGE_NAME

Check for available upgrades:

Yum check-update

3.3 Uninstall

Yum erase | remove PACKAGE_NAME

Note: other packages that depend on the specified package will be uninstalled as well.

3.4 query

Yum list

Make a list of all installable software

Yum info PACKAGE_NAME

List package information

Yum search KEYWORD

Fuzzy query package name or package sumary information based on keywords including the related list of this KEYWORD

Yum provides | whatprovides / path/to/somefile

List the files provided by the software package

3.5 charter management

Show all package groups:

Yum grouplist

Displays information about a package group:

Yum groupinfo "GROUP_NAME"

Install the package group:

Yum groupinstall "GROUP_NAME"

Or

Yum install @ GROUP_NAME quotation marks can be added or not

Uninstall the package group:

Yum groupremove "GROUP_NAME"

Yum remove @ "GROUP_NAME"

Upgrade package group:

Yum groupupdate "GROUP_NAME"

Download the rpm package from the yum repository

Yumdownloader-resolve PACKAGE_FILE...

-- destdir DIR

Specify the download destination directory. The default is the current directory.

-- urls

Instead of downloading the RPM package, list the URLs that will be downloaded

-- resolve

When downloading the RPM package, resolve the dependencies, and download the required package

-- source

Instead of the downloaded binary RPM package, download the source RPM package

The 3.7yum command can also install local rpm package files

Yum localinstall / path/to/rpm_package_file...

Install the local rpm package

Options:

-- enablerepo= enables a yum warehouse

-- disablerepo= disables a yum repository

Note: priority is higher than attributes defined in / etc/yum.repos.d/*.repo configuration file

-y: the automatic answer is yes

-- nogpgcheck: do not verify the source and integrity of the package

IV. Compilation of the package manager

What is the compilation and installation?

On linux, sometimes some programs need to be customized, and there may be a lot of built-in functions, but what we need is only a part of what we need. When the installation with yum can't provide the services we need, we will compile and install it. Compilation installation is to compile the source code into an executable file that we can use.

2. Compilation process Testapp-VERSION-release.src.rp.---- > after installation, use the rpmbuild command to make the rpm package in binary format-> install

Step 1: because SRPM needs to be recompiled, during the compilation process, we need at least the programs related to make and other compiling languages such as gcc, c, C++ to compile. At the same time, install "Development Tools" and "Server Platfrom Development" development components.

Step 2: configure script

Options: specify installation location, specify enabled features

-- help: get the options it supports

Option classification:

Installation path setting:

-- prefix=/PATH/TO/SOMEWHERE: specify the default installation location. Default is / usr/local.

-- sysconfdir=/PATH/TO/SOMEWHERE: configuration file installation location

Step 3: make

Step 4: make install

Step 5: configuration after installation

(1) Export the binary program directory to the PATH environment variable:

Edit file / etc/profile.d/NAME.sh

Export PATH=/PATH/TO/BIN:$PATH

(2) Export the path of the library file

Edit / etc/ld.so.conf.d/NAME.conf

Add the directory where the new library file is located to this file

Let the system regenerate the cache ldconfig [- v]

(3) Export header file

A link-based approach to:

Ln-sv

(4) Export help manual

Edit / etc/man.config file

Add a MANPATH

Tip: if configure is installed as the default path, there is no need for post-installation configuration files.

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

Network Security

Wechat

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

12
Report