System Package management for Linux

Source: Internet
Author: User
Tags gpg parent directory asymmetric encryption yum repolist

Rpm

We know that the programs that are used on top of the operating system are developed by programmers through development tools, and the plain text written by programmers is what we call source code. Because computers only know the binary, the programmer writes good source code to be compiled into a computer-aware binary program. And the compilation is to turn the source code into binary, and then through a certain number of steps to install on the operating system is used by us.

Although the original code for software compilation, after all, not everyone will be the original code compiled. If my Linux system is the same as the publisher, then the program compiled on the vendor's system will naturally run on our system. Since we are using the vendor's distribution, it is no problem to use the software compiled on the vendor's system.

When installing, you can also add some information related to these programs, and set him up as a database, then you can install, anti-installation, upgrade and verification and other related functions. Common Linux Software Installation methods are Redhat rpm and Debian dpkg.

RPM is a way to install it by pre-compiling and packaging it into the RPM file format, and can also be documented in the database.

Package Manager
    • Components of a binary application:
      binary files, library files, configuration files, Help files
    • Package Manager:
      Debian:deb file, dpkg Package Manager
      redhat:rpm file, RPM Package Manager
      Rpm:redhat Package Manager
      RPM Package Manager

Source code:NAME-VERSION.TAR.GZ|BZ2|XZ
VERSION:major.minor.release
PM Package Naming method:
name-version-release.arch.rpm
Example: bash-4.2.46-19.el7.x86_64.rpm
VERSION:major.minor.release
Release:release. OS
Common arch:
X86:i386, i486, i586, i686
X86_64:x64, x86_64, AMD64
Powerpc:ppc
platform agnostic:Noarch

Package: Sorting and unpacking

Application-VERSION-ARCH.rpm: 主包Application-devel-VERSION-ARCH.rpm 开发子包Application-utils-VERSION-ARHC.rpm 其它子包Application-libs-VERSION-ARHC.rpm 其它子包**包之间:可能存在依赖关系,甚至循环依赖

To resolve the dependency package management tool:

    • YUM:RPM Package Manager Front-end tools
    • Apt-get:deb Package Manager Front End Tool
    • RPM front-end management tools on Zypper:suse
    • Dnf:fedora + RPM Package Manager front-end management tool

Library files

    • View the library files that the binaries depend on * *
      ldd/path/to/binary_file***
    • Manage and view native-mounted library files
      Ldconfig Loading library files
      Sbin/ldconfig-p: Displays all available library file names and file path mappings that have been cached by this computer
      configuration files:/etc/ld.so.conf,/etc/ld.so.conf.d/\. conf**
      Cache files:/etc/ld.so.cache***
RPM Package Management

Using the RPM command management package on the CentOS system:
Installation, uninstallation, upgrade, query, checksum, database maintenance

Installation:

RPM {-i|--install} [install-options] package_file ...
-v:verbose
-VV:
-H: Show package Management execution progress with #
RPM-IVH Package_file ...

RPM Package Installation
[Install-options]

    • --test: Test installation, but do not actually perform the installation, that is, dry run mode
    • --nodeps: Ignoring dependencies
    • --REPLACEPKGS Cover Package
    • --replacefiles Overwrite files (when two packages have the same file, the default is not to install.) )
    • --nosignature: Does not check the legitimacy of the source
    • --nodigest: Package integrity is not checked
    • --noscripts: Does not execute Package script
      %pre: Pre-installation;--nopre
      %post: Post-installation script;--nopost
      %preun: Unloading the forefoot;--nopreun
      %postun: Post-uninstall script;--nopostun

Upgrade:

    • RPM {-u|--upgrade} [install-options] package_file ...
      Upgrade: Install an older version of the package, then "Upgrade"
      If there is no legacy package, the Install
    • RPM {-f|--freshen} [install-options] package_file ...
      Freshen: Install an older version of the package, then "Upgrade"
      If the legacy package does not exist, the upgrade operation is not performed
      RPM-UVH Package_file ...
      RPM-FVH Package_file ...
      --oldpackage: Downgrade
      --force: Forced installation

Upgrade Notes

Attention:

  • Do not upgrade the kernel, Linux supports multi-core version coexistence, therefore, to install the new version of the kernel directly
  • If the original package configuration file has been modified after installation, upgrade, the new version of the same profile provided does not directly overwrite the old version of the configuration file, and the new version of the file is renamed (filename.rpmnew) after the retention
  • In the upgrade, the binary overwrite is not overwritten with the configuration file.
  • The Linux kernel allows multiple versions to coexist, install kernels, do not install with-UVH and-FVH, and should be installed with-IVH. The system starts with only one kernel to boot,

Package Query
RPM {-q|--query} [select-options] [query-options]
[Select-options]

    • -A: All packages
    • -F: To see which package installs the specified file for build
    • -P rpmfile: query operation for package files not yet installed
    • --whatprovides CAPABILITY: Query which package is supplied by the specified CAPABILITY
    • --whatrequires CAPABILITY: Query which package the specified CAPABILITY is dependent on
    • Rpm2cpio Package Files |cpio–itv Preview in-Package files
      Rpm2cpio package file |cpio–id "*.conf" release in-Package files

[Query-options]

    • --changelog: Query rpm Package for Changelog
    • -C: Querying the program's configuration file
    • -D: Querying the program's documentation
    • -i:information
    • -L: View all files generated after the installation of the specified package
    • --scripts: script that comes with the package
    • --provides: Lists the capability provided by the specified package
    • -r: Query the capability that the specified package depends on

Package Offload:

RPM {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] package_name ...

Package Check

Once a package is installed, the/VAR/LIB/RPM database is automatically updated. It records the metadata of each file within the package.
Whether the files generated after the query package installation have changed,
Common usage:
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

Package Check

    • Verification and completeness of the legitimacy of package source
      Integrity Verification: SHA256
      SOURCE legality verification: RSA
    • Public Key Cryptography
      Symmetric encryption: Encrypt, decrypt using the same key
      Asymmetric encryption: The key is in pairs
      Public key: Private key, public owner
      Secret key: Private key, cannot be exposed
      Import the required public key

      Rpm-k|checksig Rpmfile Check Package integrity and signature
      RPM--import/etc/pki/rpm-gpg/rpm-gpg-key-centos-7
      RPM--import/run/media/root/centos\ 7\ x86_64/rpm-gpg-key-centos-7
      CentOS 7 Release CD offers: Rpm-gpg-key-centos-7
      Rpm-qa "Gpg-pubkey
      "
      Rpm-qi gpg-pubkey-f4a80eb5-53a7ff4b
      Cat/etc/pki/rpm-gpg/rpm-gpg-key-centos-7
      RPM-E gpg-pubkey-f4a80eb5-53a7ff4b *

RPM Database

    • Database rebuild:
      /var/lib/rpm
    • RPM {--INITDB|--REBUILDDB}
      INITDB: Initialization
      If the database does not exist beforehand, the new
      Otherwise, no action is taken
      REBUILDDB: Rebuilding the database index directory for an installed header
Yum

Since RPM has a software-dependent problem, when there are multiple packages dependent on each other, is there a breath of software to install and rely on the software installed it? Yum is based on the C/s structure.
Yum server has some RPM packages and some meta-data, all the RPM packages to be released on the Yum server to provide others to download, yum server as long as the simple download can be, FTP or httpd form can be.
Each time the client uses Yum, it will parse all of the configuration files that end with. Repo in/ETC/YUM.REPOS.D, which specify the address of the Yum server.

Yum
    • Centos:yum, DNF
    • Yum:yellowdog Update modifier,rpm front-end program to address package dependencies, locate packages between multiple libraries, up2date alternative tools
    • Yum Repository:yum repo, which stores a wide range of RPM packages and related metadata files for packages (placed in a specific directory repodata)
      File server:
      /HTTP
      https://
      ftp://
      file://
Yum configuration file

? Yum Client configuration file:
/etc/yum.conf: providing public configuration for all warehouses
/etc/yum.repos.d/*.repo: Provides configuration for the point of the warehouse

Definition of Warehouse Point

    • [main] statement block name
    • cachedir=/var/cache/yum/$basearch/$releasever
      Cached Folder <br/ > $basearch is the CPU architecture, $releasever the path to the version
    • baseurl=url://path/to/repository/ Yum Warehouse, When the Yum repository points to multiple paths, multiple paths can be placed in a file, and the path of the repository points to the path of the file: <br/>mirrorlist=file:///root/baselist
    • Keepcache=0 1 o'clock, when the RPM package is downloaded, the package will be cached and will be deleted by default
    • debuglevel=2 debug
    • enabled={1|0} Disable the warehouse for 0 o'clock and enable the warehouse for 1 o'clock
    • logfile=/var/log/yum.log Log
    • exactarch=1
    • Obsoletes=1
    • gpgcheck=1 is equivalent to Rpm-k, 1, the package is not complete and illegal, the installation is denied, 0 o'clock, ignore check
      Gpgkey=url Import public key
      gpgkey=file:/// Mnt/cdrom/rpm-gpg-key-centos-7
    • plugins=1 plugin enabled
    • installonly_limit=5 parallel installation, accelerated access
    • enablegroups={1|0}
    • failovermethod={roundrobin|priority}
      Roundrobin: Random selection, default value
      Priority: Sequential access to
    • cost= default to 1000 ' smaller precedence higher

Yum Features: It is not allowed to run multiple Yum commands concurrently on one machine.
use the CD to do the Yum source . On the CD: the RPM package is in the packages directory, and the meta data is in the Repodata directory.
principle: The future path to the repository is written in Repodata's parent directory

Yum Warehouse
The variables available in the Yum repo configuration file:
$releasever: Major version number of the current OS release
$arch: Platform, i386,i486,i586,x86_64, etc.
$basearch: basic platform; i386, x86_64
$YUM 0-$YUM 9: Custom variables
Instance
http://server/centos/$releasever/$basearch/
Http://server/centos/7/x86_64
http://server/centos/6/i384

Yum Command
  • Usage of the Yum command:
    Yum [options] [command] [package ...]
  • Show Warehouse list:
    Yum Repolist [all|enabled|disabled]
  • Show Packages:
    Yum List
    Yum list [All | glob_exp1] [GLOB_EXP2] [...]
    Yum list {available|installed|updates} [GLOB_EXP1] [...]
  • To install the package:
    Yum install Package1 [Package2] [...]
    Yum Reinstall Package1 [Package2] [...] (reinstall)

  • Upgrade Package:
    Yum Update [Package1] [Package2] [...]
    Yum downgrade Package1 [Package2] [...] Downgrade
  • Check for available upgrades:
    Yum Check-update
  • To uninstall a package:
    Yum Remove | Erase Package1 [Package2] [...]

  • To view the package information:
    Yum info [...]
  • View which package is provided by the specified attribute (which can be a file):
    Yum provides | Whatprovides Feature1 [Feature2] [...]
  • To clean up the local cache:
    Clear/var/cache/yum/$basearch/$releasever Cache
    Yum Clean [Packages | metadata | expire-cache | rpmdb | plugins | all]
  • Build cache:
    Yum Makecache

  • Search:yum search string1 [string2] [...]
    Search for Package name and summary information with the specified keyword
  • View the capabilities that the specified package depends on:
    Yum deplist package1 [Package2] [...]
  • View Yum Transaction history:
    Yum History [info|list|packages-list|packages-info|
    summary|addon-info|redo|undo|
    Rollback|new|sync|stats]
    Yum history
    Yum History Info 6查看
    Yum History undo 6取反
    Yum History Redo 6重做
  • log:/var/log/yum.log

  • * * Install and upgrade the local package: * * *
    Yum Localinstall rpmfile1 [Rpmfile2] [...]
    (Replace with install)
    Yum localupdate rpmfile1 [Rpmfile2] [...]
    (Replace with update)
  • Related commands for package group management:
    Yum Groupinstall group1 [group2] [...]
    Yum groupupdate group1 [group2] [...]
    Yum grouplist [Hidden] [Groupwildcard] [...]
    Yum Groupremove group1 [group2] [...]
    Yum GroupInfo group1 [...]

  • Yum command-Line options:
    --nogpgcheck: No GPG check
    -Y: Auto Answer "yes"
    -Q: Silent mode
    --disablerepo=repoidglob: Temporarily disables the repo specified here
    --enablerepo=repoidglob: Temporarily enable the repo specified here
    --noplugins: Disable all plugins
System CD Yum Warehouse
    • The system installation CD is used as the local Yum repository:
      (1) Mount the disc to a directory such as/mnt/cdrom
      Mount/dev/cdrom/mnt/cdrom
      (2) Creating a configuration file
      [CentOS7]
      Name=
      Baseurl=
      gpgcheck=
      Enabled=
    • To create a yum repository:
      Createrepo [Options] <directory>

System Package management for Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.