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 Management (CentOS)

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

Share

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

Components of a binary application:

Binaries, library files, configuration files, help files

Package Manager:

Debian:deb, dpt

Redhat: rpm, rpm

Rpm: Redhat Package Manager (RPM is Package Manager)

Source code: name-VERSION.tar.gz

VERSION: major.minor.release

How the rpm package is named:

Name-VERSION-release.arch.rpm

VERSION: major.minor.release

Release:OS

Common arch:

X86: i386, i486, i586, i686

X86_64: x64, x86_64, amd64

Powerpc: ppc

Platform independent: noarch

Testapp: unpacking

Testapp-VERSION-ARCH.rpm: main package

Testapp-devel-VERSION-ARCH.rpm: subcontractor

Testapp-testing-VERSION-ARHC.rpm

Between packages: there are dependencies

Front-end tools for yum:rpm package manager

Apt-get:deb package Manager front-end tools

Zypper: rpm front-end management tool on suse

Dnf: Fedora 22 + rpm package Manager front-end management tool

View the library file on which the binary depends: ldd / PATH/TO/BINARY_FILE

Manage and view the 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

The configuration file is: / etc/ld.so.conf, / etc/ld.so.conf.d/*.conf

Cache file: / etc/ld.so.cache

Package Management:

Function: package one or more package files from each component file of the compiled application, so as to easily and quickly realize the management operations such as installation, uninstallation, query, upgrade and verification of the package.

1. The composition list of the program (unique to each package)

List of files, scripts to run when installing or uninstalling

2. Database (public)

Package name and version, dependency, function description, file path and check code information of each file generated by installation

How to manage packages:

Use the package manager: rpm

Use front-end tools: yum, dnf

The way to get the package:

(1) the CD-ROM of the system version or the official server

CentOS image:

Http://mirrors.aliyun.com, http://mirrors.sohu.com, http://mirrors.163.com

(2) official site of the project

(3) third-party organizations:

Fedora-EPEL

Search engine:

Http://pkgs.org, http://rpmfind.net, http://rpm.pbone.net

(4) make it yourself.

Suggestion: check its legality, source legitimacy, and package integrity

The rpm command management package on CentOS systems:

Installation, uninstallation, upgrade, query, verification, database maintenance

Installation:

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

-v: verbose

-vv:

-h: displays the progress of package management execution in #; each # represents a 2% progress

Rpm-ivh PACKAGE_FILE...

[install-options]

-- test: test the installation, but do not actually perform the installation process; dry run mode

-- nodeps: ignore dependencies

-- replacepkgs: reinstall

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

-- nodigest: do not check package integrity

-- noscipts: do not execute package script fragments

% pre: pre-installation script;-- nopre

% post: post-installation script;-- nopost

% preun: pre-uninstall script;-- nopreun

% postun: script after uninstallation;-- nopostun

Upgrade:

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

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

Upgrage: upgrade if a legacy package is installed, or install if there is no legacy package

Freeshen: upgrade if an old version of the package is installed; if no old version of the package exists, no upgrade will be performed

Rpm-Uvh PACKAGE_FILE...

Rpm-Fvh PACKAGE_FILE...

-- oldpackage: downgrade

-- force: force upgrade

Notes:

(1) do not upgrade the kernel; Linux supports the coexistence of multiple kernel versions, so you can install a new version of the kernel directly.

(2) if the configuration file of the original package has been modified after installation, the same configuration file provided by the new version will not directly overwrite the configuration file of the old version, but the new version of the file will be renamed (FILENAME.rpmnew) and retained.

Query:

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

[select-options]

-a: all packages

-f: check which package installation generates the specified file

-p / PATH/TO/PACKAGE_FILE: query for package files that have not been installed

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

-- whatrequires CAPABILITY: query which package the specified CAPABILITY is dependent on

[query-options]

-- changelog: query the changlog of the rpm package

-c: the configuration file of the query program

-d: query the documentation of the program

-I: information

-l: view all files generated after the specified package is installed

-- scripts: script snippet that comes with the package

-R: query the CAPABILITY on which the specified package depends

-- provides: lists the CAPABILITY provided by the specified package

Uninstall:

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

Check:

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

S file Size differs

M Mode differs (includes permissions and file type)

5 digest (formerly MD5 sum) differs

D Device major/minor number mismatch

L readLink (2) path mismatch

U User ownership differs

G Group ownership differs

T mTime differs

P caPabilities differ

Validity verification and integrity verification of package source:

Integrity verification: SHA256

Verification of Source legitimacy: RSA

Import the required public key:

Rpm-import / PATH/FROM/GPG-PUBKEY-FILE

Key file provided on CentOS 7 distribution CD: RPM-GPG-KEY-CentOS-7

Database Reconstruction:

Rpm {--initdb |-- rebuilddb}

Initdb: initialization

If the database does not exist in advance, create a new database; otherwise, no action is performed

Rebuilddb: rebuilding

Recreate the database directly, whether it currently exists or not

Summary of rpm commands:

Install:-ivh,-- nodeps,-- replacepkgs

Uninstall:-e,-- nodeps

Upgrade:-Uvh,-Fvh,-- nodeps,-- oldpackage

Query:-Q,-qa,-qf,-qi,-qd,-qc,-Q-- scripts,-Q-- changlog,-Q-- provides,-Q-- requires

Check:-V

Import GPG key:-- import,-K,-- nodigest,-- nosignature

Database reconstruction:-- initdb,-- rebuilddb

Yum package Management:

YUM: yellow dog, Yellowdog Update Modifier

Yum repository: yum repo

Stores a large number of rpm packages and related metadata files for the package (placed in a specific directory: repodata)

File server:

Ftp://, http://, nfs://, file:///

Yum client:

Configuration file:

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

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

The definition of the warehouse point:

[repositoryID]

Name=Some name for this repository

Baseurl=url://path/to/repository/

Enabled= {1 | 0}

Gpgcheck= {1 | 0}

Gpgkey=URL

Enablegroups= {1 | 0}

Failovermethod= {roundrobin | priority}

The default is: roundrobin, which means random selection

Cost=: defaults to 1000

Usage of the yum command: yum [options] [command] [package.]

Display a list of warehouses:

Repolist [all | enabled | disabled]

Display the package:

List

# yum list [all | glob_exp1] [glob_exp2] [...]

# yum list {available | installed | updates} [glob_exp1] [...]

Install the package:

Install package1 [package2] [...]

Reinstall package1 [package2] [...] (reinstall)

Upgrade package:

Update [package1] [package2] [...]

Downgrade package1 [package2] [...] (demoted)

Check for available upgrades:

Check-update

Uninstall the package:

Remove | erase package1 [package2] [...]

View the package information:

Info [...]

To see which package the specified feature (which can be a file) is provided:

Provides | whatprovides feature1 [feature2] [...]

Clean up the local cache:

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

Build the cache:

Makecache

Search for:

Search string1 [string2] [...]

Search for package name and summary information with specified keywords

View the capabilities on which the specified package depends:

Deplist package1 [package2] [...]

View yum transaction history:

History [info | list | packages-list | packages-info | summary | addon-info | redo | undo | rollback | new | sync | stats]

Install and upgrade local packages:

Localinstall rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only-use install)

Localupdate rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only-use update)

Commands related to package group management:

Groupinstall group1 [group2] [...]

Groupupdate group1 [group2] [...]

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

Groupremove group1 [group2] [...]

Groupinfo group1 [...]

How to use CD as a local yum repository:

(1) Mount the CD to a directory, such as / media/cdrom

# mount-r-t iso9660 / dev/cdrom / media/cdrom

(2) create a configuration file

[CentOS7]

Name=

Baseurl=

Gpgcheck=

Enabled=

Command line options for yum:

-- nogpgcheck: gpgcheck is prohibited

-y: automatic answer is "yes"

-Q: silent mode

-- disablerepo=repoidglob: temporarily disable the repo specified here

-- enablerepo=repoidglob: temporarily enable the repo specified here

-- noplugins: disable all plug-ins

Variables available in yum's repo configuration file

$releasever: the major version number of the current OS release

$arch: platform

$basearch: basic platform

Create a yum repository:

Createrepo [options]

Package compilation and installation:

After testapp-VERSION-release.src.rpm-- > installation, use the rpmbuild command to make the rpm package in binary format, and then install it

Source code-- > preprocessing-- > compilation (gcc)-- > assembly-- > link-- > execution

Source code organization format:

Multiple files: there are likely to be cross-file dependencies between the code in the file

C, Clearing: make (configure-- > Makefile.in-- > makefile)

C code compilation and installation three steps:

. / configure:

(1) pass parameters through options to specify the enabled feature, installation path, etc. During execution, you will refer to the user's assignment and Makefile.in file to generate makefile.

(2) check the external environment on which it depends

Make:

Build the application based on the makefile file

Make install

Move the application to the specified location

Development tools:

Autoconf: generate configure script

Automake: generate Makefile.in

Recommendation: check INSTALL,README before installation

Access to source code of open source programs:

Official self-built site:

Apache.org (ASF)

Mariadb.org

...

Code hosting:

SourceForge

Github.com

Code.google.com

C _ blank: gcc (GNU C Complier)

Compile the C source code:

Premise: provide development tools and development environment

Development tools: make, gcc, etc.

Development environment: development libraries, header files

Glibc: standard library

Provide development components through "package groups"

CentOS 6: "Development Tools", "Server Platform Development"

Step 1: 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

System types:

Optional Features: optional featur

-- disable-FEATURE

-- enable-FEATURE [= ARG]

Optional Packages: optional package

-- with-PACKAGE [= ARG]

-- without-PACKAGE

Step 2: make

Step 3: make install

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

Link-based implementation

Ln-sv

(4) Export help manual

Edit / etc/man.config file

Add a MANPATH

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