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

Linux package managers rpm and yum

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

In our operation and maintenance work, we can't avoid installing some software, or compiling and installing some software. we know that all programs in the operating system are developed by programmers through development tools. the plain text documents written directly by programmers are called source code, but our computer can only recognize binary programs, so we must turn the source code into binary programs that the computer can recognize. Here, you need to compile through the compiler, convert the source code into a binary program, and then install it.

Another kind of program is the binary program, the system is done by some manufacturers, and the program compiled on the manufacturer's system naturally runs on the system, where the manufacturer compiles the program directly and then releases it to the user. in this way, since we already use the manufacturer's distribution version, the system is the same, so there is no problem using the compiled program provided by the manufacturer. First of all, let's introduce the environment in which the software runs.

"Software running environment

API:Application Programming Interface

POSIX: Portable OS

Program source code-à preprocessing-à compilation-à assembly-à link

Static compilation: when compiling an executable file, the compiler extracts the part of the corresponding dynamic link library (.so or .lib) that the executable file needs to call and links it to the executable file, so that the executable file does not depend on the dynamic link library at run time.

Shared compilation: extract the library and link it to the executable file to achieve shared compilation

ABI:Application Binary Interface

Windows is not compatible with linux

ELF (Executable and Linkable Format)

PE

Virtualization at the library level

Linux:WINE

Windows:Cywin

Package Manager

Components of a binary application:

Binaries, library files, configuration files, help files, header files

Package Manager

Package one or more package files with compiled application files, so as to easily and quickly install, uninstall, query, upgrade, and verify packages. At present, there are two most common ways to install software on Linux systems:

Dpkg

This mechanism was first developed by the Debian Linux community. Through the dpkg mechanism, the software provided by Debian can be easily installed and provide software information after installation, which is really very good. Based on Debian derivative systems, such as B2DMagol Ubantu, etc., all use dpkg to manage the software.

RPM

This mechanism was first developed by redhat, and later it was found to be very easy to use, so many distributions use this machine as the manager of software packages such as SuSe,Fedora,CentOS.

However, the mechanisms of the two package managers mentioned above will more or less have the problem of dependence of software properties. in fact, during installation, each file provides dependency checking, so if we make a list of dependent data and wait until installation, if there is a dependency, through the dependent data list, the management mechanism will install the dependent software at the same time.

Package Command Rul

Source code:

Name-version.tar.gz | bz2 | xz

Version:major (major version number). Minor (minor version number). Release (release number)

For example, the name of the httpd-2.4.6.tar.bz2 package is httpd, the major version number is 2 times, the release number is 4, and the release number is 6 (which also means modified 6 times), followed by storage in a packaged and compressed way.

How rpm packages are named

Name-version-release.arch.rpm

For example: bash-4.2.46-19.el7.x86_64.rpm

The package name is bash. The major version number is 4, the minor version number is 2, and the modification number is 46. The suitable hardware platform is el7.x86.

Major version number: when a new feature is introduced, it needs to be updated when the major version number is updated, or when some features have changed greatly.

Minor version number: same as the major version number, the minor version number update is only local, but there are still more important improvements and enhancements, which need to be changed.

Revision number: local variables, usually just to fix bug, or a simple function extension

Therefore, the main version number is the most stable, the change period is long, the change number updates quickly, and the change period is short.

Common arch

X86:i386,i486,i586,i686

X86_64:x64,x86_64,amd64

Powerpc:ppc

Platform independent: noarch

Packet classification and unpacking

Application-version-arch.rpm: main package

Application-devel-version-arch.rpm development subpackage

Other subpackages of Application-utils-version-arch.rpm

Other subpackages of Application-libs-version-arch.rpm

Resolve dependency package management tools

Front-end tools for yum:rpm package manager

Apt-get:deb package Manager front-end tools

Rpm front-end management tools on zipper:suse

Rpm package Manager front-end tools for dnf:Fedora version 18 and above

Library files:

View the library files on which the binary depends

Ldd / path/to/binary_file

For example: ldd / bin/ls

Manage and view library files loaded on this machine

Ldconfig

/ sbin/ldconfig-p: displays all available library file names and file path mapping relationships that have been cached on this machine

Configuration file: / etc/ld.so.conf, / etc/ld.so.conf.d*.conf

Cache file: / etc/ld.so.cache

Package source

System CD

Project official site

Third-party organizations such as Fedora EPEL (Extra Packages for Enterprise Linux)

Make it yourself

"RPM

Advantages

Rpm contains data such as compiled programs and configuration files, which allows users to avoid the trouble of recompiling.

Before being installed, rpm will check the hard disk capacity of the system, the version of the operating system, and avoid files being installed incorrectly.

The rpm file itself provides software version consultation, dependent software name, software usage description and software meaning to facilitate understanding of the software.

Rpm management is divided into installation, uninstallation, upgrade, query, inspection and database maintenance.

Installation:

Rpm {I | install} [install-option] PACKAGES_FILE...

-h:hash, with # for installation progress, and each # for% 2

-v |-verbose: displays the detailed process

-vv: show a more detailed process

[install-option]

Rpm-ivh-test: test the installation, but do not actually perform the installation; in dry run mode

Rpm-ivh-- nodeps: ignore dependencies

Rpm-ivh-- replacepkgs: reinstall, replace the original installation

Rpm-ivh-- nosignature: do not check source legality

Rpm-ivh-- nodigest: do not check package integrity

Rpm-ivh-- force: forced installation, can be reinstalled or downgraded

Rpm-ivh-- scripts: do not execute snippets of package scripts

Query:

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

Rpm-Q packages_name: query whether the specified package is installed

Rpm-qa: query all installed packages

Rpm-qi packages_name: query the description of the specified package

Rpm-ql packages_name: query the files generated by the specified installation package

Rpm-qc packages_name: query the configuration files generated by the specified installation package

Rpm-qd packages_name: query the help files generated by the specified installation package

Rpm-qf files_name: the file specified by the query is generated by that package installation

Rpm-qp files_name: query specified uninstalled package files for query operation

-whatprovides capability: query the specified capability provided by that package

-whatrequires capability: the capability specified by the query is dependent on that package

Rpm-Q-scripts packages_name: view the scripts contained in the specified package

Rpm-Q-changelog packages_name: query the rpm package change log

Rpm-R packages_name: query the capabilty since the specified package

Rpm2cpio package file | cpio-itv preview the files in the package

Rpm2cpio package files | cpio-id "* .conf" release the files in the package

Upgrade:

Rpm {- U |-upgrade} [install-options] PACKAGES_FILE... Upgrade if there is an older version, otherwise, install

Rpm {- F |-freshen} [install-options] PACKAGES_FILE... Upgrade if there is an older version, otherwise, exit the installation

-oldpackages: downgrade

Note:

Do not upgrade the kernel; Linux supports the coexistence of multiple kernel versions, so install a new version of the kernel directly

If the configuration file of the source package has been modified after installation, when upgrading, the same configuration file provided by the new version will not overwrite the configuration file of the old version, but the new version of the file command will be retained as the .rpmnew file.

Uninstall:

Rpm {- e |-erase} [- allmatches] [- nodeps] [- test] PACKAGES_NAME

Simple usage: rpm-e packages_name

-nodeps: ignore dependencies

-test: test uninstall; dry-run mode

-allmatches: if a package installs multiple versions at the same time, this option is uninstalled all at once, but the package configuration file has been modified after installation. When uninstalled, this document is usually not deleted, but is retained by a file renamed .rpmsave.

Check:

Query whether the files generated after the package installation have changed

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

Common usage: rpm-V packages_name

When there is no output result, it indicates the complete ok of the package. When there is a corresponding result output, the corresponding content has been modified, as shown below:

The capacity size of the S file Size differs file has changed

The content of 5 (MD5 sum differs) MD5 fingerprint code has been changed.

The type or properties of the M Mode differs file have changed

The major and minor version numbers of the D Device major/minor number mismatch device have changed

L readLink (2) path mismatch link path changed

The owner of the U User ownership differs file has changed

The grouping of the G Group ownership differs file has changed

The creation time of the T mTime differs file has changed

P capabilities differ capabilities have changed

Note: it is best to verify the validity of the software to be installed before installing the software, so that you can check whether the source and content of the software are legitimate, and to a certain extent avoid some unsafe things caused by unsafe factors.

The legal source means that it is provided by a producer we trust; it depends on the autographed signature, which is the characteristic code of the author's encryption package using his own private key.

Legal content means that the package has not been modified twice; the success of integrity verification depends on the program signature provided by the producer.

Verification method: install and use the same signature extraction algorithm to extract the signature of the package and compare it with the one provided by the original author

Import key

Rpm- import / etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Verify rpm-K packages_name

Rebuild the database

When we delete the files in the database, we cannot query the information of the software package, because rpm-Q is queried based on the data in the database, so we need to rebuild the database.

Database location

/ var/lib/rpm

Rpm {- initdb |-rebuilddb}

Rpm-initab: initialize. If the database does not exist in advance, create a new one. Otherwise, no action is performed.

Rebuilddb: rebuild the database directly, regardless of whether it exists beforehand or not

"yum

After analyzing the header file data of rpm, yum:Yellowdag Update Modifier,yum makes a solution when there is a dependency relationship according to the dependency relationship of each software, and then can automatically deal with the problem of software dependency to solve the problem of software installation or removal and upgrade. So we want to use yum must first find a suitable yum server, and each yum server may provide many different software functions, yum server will be classified according to function, the classification here is the so-called warehouse, yum repository stores a large number of rpm packages, as well as report-related metadata files are placed in a specific directory repodate

Metadata File in yum Warehouse

Primary.xml.gz: a list of all rpm packages, dependencies, and a list of files generated by each rpm installation

Filelists.xml.gz: a list of all files for all rpm packages in the current warehouse

Other.xml.gz: additional information, modification log of rpm package

Repomd.xml: record the timestamp and verification of the above three files

Coms*.xml.:rpm packet information

Yum client profile

/ etc/yum.conf: provide common configuration for all warehouses

/ etc/yum.repos.d/*.repo: provides configuration for pointing to the warehouse

Definition of warehouse:

[reposirtoryID] Secondary repository is used to indicate this repository execution, and the only

Name= description description of the warehouse

Baseurl=url://path/to/repository specifies the access path to the repository, which is usually the repository output on a file server and the path in the same directory as repodata.

Http://10.1.0.1/cobbler/ks_mirror/7/

Ftp://10.1.0.1/iso/7

File:///mnt/

Enabled= {1 | 0} whether to enable warehouse 1 means to start, 0 means to disable

Gpgcheck= {1 | 0} whether to verify the package. 1 indicates verification, 0 indicates no verification.

Gpgkey= file://etc/pki/rpm-gpg/RPM-GPG-CentOS-6 indicates the gpgkey file path

Cost=# # represents a number and indicates the access cost of the current warehouse. The default is 1000. The smaller the value, the higher the priority.

Yum-config-manager

Yun-config-manager-disable "repository_name" disables this repository

Yun-config-manager-enable "repository_name" enables this warehouse

Introduction to yum command

Show warehouse list

Yum repolist [all | enabled | disabled]

All: lists all available repositories that have been configured

Disable: lists disabled warehouses

Enabled: list the warehouses started

Show package

Yum list [all | glob_expr1] [glob_expr2] lists all packages

Yum reinstall [packeages] reinstall the specified package

Yum grouplist group1 group2 […] View the specified package group, do not specify the group to view all groups

Install the package

Yum install packages [packages2] […] Install a package

Yum groupinstall packages [packages2] […] Installation package group

When installing some software, sometimes you need to rely on certain installation packages, and yum will automatically resolve the dependency.

Upgrade package

Yum update [packages1] [packages2] […] Upgrade

Yum downgrade packages1 [packages2] […] Downgrade

Check availability

Yum check-update

Uninstall the package

Yum remove | erase packages1 [packages2] […] Delete package

Yum groupremove | erase packages1 [packages2] […] Delete package group

View package information

Yum info displays information about all packages. This function is similar to rpm-qi.

Yum info packages displays information about the specified package

Yum groupinfo gropu1 displays information for the specified package group

Clean up the local cache

Yum clean cleans up cache

Yum clean [packages] metadata | expire-cache | rpmdb | pkugins | all]

Build cach

Yum makecache

View the history of yum things

Yum history [info | list | packages-list | packages-info | summary | addon-info | redo | undo]

Yum history: show all historical things

Yum history info 6 displays information about specified historical things

Yum history undo 6: if the sixth step is to install, uninstall here, and vice versa

How to create a local yum repository

1. Mount the local CD, such as / mnt

# mount / dev/cdrom / mnt/

2. Create a warehouse

Vim / etc/yum.repos.d/base.repo

[cdrom]

Name=123

Baseurl= file:///mnt

Enabled=1

Gpgcheck=0

Here, the local yum warehouse will be configured.

Command line options for yum

-nogpgcheck: gpgcheck is prohibited

-y: the automatic answer is yes

-Q: silent mode

-disablerepo=repoidglob: temporarily disable the repo specified here

-enabledrepo=repoidglob: temporarily start the repo specified here

-noplugins: disable all plug-ins

Compilation and installation

1. C code compilation and installation three steps

Pass parameters through the option, specify the enabled feature and the installation path, and check the external environment as soon as it is executed with reference to the user's assignment and the makefile generated by the makefile.in file.

2. Make: build the application according to the makefile file

3. Makeinstall copies files to the appropriate path

Development tools:

Autoconf: generate configure script

Automake: generating makefile.in fil

Compile Cyuandaima

Premise: provide development tools and development environment

Development tools: make,gcc, etc.

Development environment: development libraries, header files, glibc standard libraries

Provide the development of the Pearl River through the installation package group

Yum groupinstall "Development Tools"

Yum groupinstall "Server Platform Development

Compilation and installation

Step 1: configure script

Options: specify installation location, specify enabled features

-help: get the options it supports

Installation path setting

-prefix=/Path: specify the default installation location. Default is / usr/loca.

-sysconfdir=/path: configuration file installation location

Optional Features: optional featur

-disable-feature

-enable-feature

Optional packages: optional package

-with-packages [= arg] dependency package

-without-package disables dependencies

Step 2: make

Step 3: make install

Configuration after installation:

(1) Import the binary program directory into the PATH environment variable

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

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

(2) Import library file path

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

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

Have the system regenerate the cache:

Ldconfig [- v]

(3) Import header file

A link-based approach to:

Ln-sv

Import help manual

Edit / etc/man.config | man_db.conf file

Add a MANPATH

1. Configuration and use of yum, including the creation of yum repository

I downloaded some rpm packages to the / root/repo directory. When there is no repodate data directory in the directory, the construction warehouse will report an error. Createrepo is needed. The default createrepo command in the system is not installed, so it needs to be installed.

Createrepo [options]

Create / root/repo

After you have created the repo data file, you need to configure the yum repository by creating a file ending with repo in the / etc/repos.d/ directory, as follows

[xen] # Warehouse name

Name=1 # Warehouse description

The path to the baseurl= file:///root/repo # warehouse

Whether enabled=1 # is enabled for warehouse 1 means enabled, and 0 means disabled

Whether gpgcheck=0 # checks the validity of the source

The default value of cost=100 # warehouse priority is 1000. The smaller the value, the higher the priority.

2. Compile and install apache 2.2, and start this service

Step 1: download the source package wget: ftp://10.1.0.1/pub/Sources/sources/httpd/ httpd-2.2.29.tar.bz2

After the download is completed, you need to extract it, and then go to this directory, where there is a script for configure.

. / configure-prefix=/usr/local/apache-sysconfdir=/etc/httpd2 (prefix specifies the installation path, sysconfdir specifies the configuration file path)

Step 2: make generation file

Step 3: make install copies the files generated by make to the specified installation directory

Step 4: export header files, library files, help documents, binaries

1. Ln-sv / usr/local/apache/include / usr/include/httpd export header file

2. Export help files

Vim / etc/man.config

MANPATH=/usr/loca/apache/man centos6

Vim / etc/man_db.conf

MANDATORY_MANPATH / usr/loca/apache/man centos7

3. Export library files

Vim / etc/ld.so.conf.d/httpd2.conf

/ usr/local/apache/lib just add this line to the file

4. Binary program

Vim / etc/profile.d/httpd.conf

Export PATH=$PATH:/usr/local/apache/bin

5. Service script

Cp / etc/rc.d/init.d/httpd / etc/rc.d/init.d/httpd24

Chmod + x / etc/rc.d/init.d/httpd

Add the following lines:

Apachectl=/usr/local/apache/bin/apachectl

Httpd=/usr/local/apache/bin/httpd

Prog=httpd

Pidfile=$ {PIDFILE=/var/run/httpd24.pid}

Lockfile=$ {LOCKFILE-/var/lock/subsys/httpd24}

RETVAL=0

STOP_TIMEOUT=$ {STOP_TIMEOUT-10}

Vim / etc/httpd24/httpd.conf

Add a row

PidFile=/var/run/httpd24.pid

Service httpd24 start can start the service.

Ss-tan to see if port 80 is listening

Use crul httpdserver to test whether the page is displayed properly. If the port is up, or you can't see the content, the firewall may be open. This is a policy that requires iptables-F to temporarily clean up the following firewalls.

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

Database

Wechat

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

12
Report