CentOS package management

Source: Internet
Author: User

CentOS package management

Package management is to package one or several package files of the compiled application, so as to conveniently and quickly install, uninstall, query, upgrade, and verify the package.

The Package Manager of CentOS 6 is rpm, the front-end tool is yum, RPM is Package Manager, and yum is Yellowdog Update Modifier. The Package Manager of debian is deb, and the front-end tool is apt-get. The rpm front-end management tool on suse is zypper.

1. Ways to obtain the package:

(1) Turn off the disk or official server of the system release version

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

Ii. rpm package management

The naming format of the source package: name-VERSION.tar.gz

VERSION: major. minor. release (main VERSION number. minor VERSION number. release number)

Rpm package naming method:

Name-VERSION-release-ARCH.rpm

Including the name, version, operating system, and applicable hardware architecture of the software package.

Common Hardware structures include arch:

X86: i386, i8.0, i586, i686

X86_64: x64, x86_64, amd64

Powerpc: ppc

Platform-independent: noarch

Database Management commands:

Ldd: view the library files that the binary program depends on

Ldd/PATH/TO/BINARY_FILE

Ldconfig: Manage and view library files loaded on the local machine

/Sbin/ldconfig-p: displays the mappings between the file names and file paths of all available libraries cached on the local machine;

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

Cache file:/etc/ld. so. cache

Package management command:

Install, uninstall, upgrade, query, verify, and maintain databases

1. Installation

Command Format: rpm {-I | -- install} [install-options] pkgs_name

Command Option:-v: Detailed Information Display

-Vv: display more details

-H: displays the package management execution progress with #. Each # indicates the progress.

Rpm-ivh pkgs_name...

-- Replace: reinstall

-- Nodeps: Ignore dependency

-- Test: test installation

-- Nodigest: the package integrity is not checked.

-- Nosignature: do not check the source Validity

-- Noscript: do not execute the package script snippet

% Pre: pre-installation script, -- nopre

% Post: post-installation script, -- nopost

% Preun: uninstall the prefix script, -- nopreun

% Postun: script after uninstallation, -- nopostun

2. Upgrade

Rpm-Uvh Package_file...

Upgrade: if an earlier version of the package is installed, upgrade it. If the earlier version of the package does not exist, "Install"

Rpm-fvl Package_file...

Freshen: if an earlier version of the package is installed, upgrade the package. If the earlier version of the package does not exist, no upgrade is performed.

Available options:

-- Oldpackage: downgrade

-- Force: force update

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

(2) If the configuration file of the source package has been modified after installation, during the upgrade, the new version provides the same configuration file

The configuration file of the old version is not overwritten, but is retained after the configuration file of the new version is renamed (FILENAME. rpmnew ).

3. Query

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

[Slect-options]

-A: All packages

-F: check which package installs and generates the specified file.

-P/PATH/TO/PACKAGE_FILE: queries uninstalled package files;

-- WhatprovideCAPABILITY: query which package provides the specified CAPABILIT.

-- WhatrequiresCAPABILITY: queries which package the specified CAPABILIT depends on.

[Query-options]

-C: query the configuration file of a program.

-D: query the program documentation.

-I: information

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

-R: queries the CAPABILITY on which the specified package depends.

-- Script: the script snippet that comes with the package

-- Provides: lists the CAPABILITY provided by a specified package.

4. Uninstall

Rpm {-e | -- erase} [option] PACKAGE_NAME...

Option: -- nodep

Uninstall:

Note: If the package configuration file has been modified after installation, it will not be deleted when it is uninstalled and will be retained in the source file name and. rpmsave.

5. Verification

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

Rpm package integrity verification (before or during package installation)

Rpm -- import/PATH/FROM/KEY_FILE: the Public Key Required for import. The key file is provided on the CentOS release disc.

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

Check the rpm package source Validity

6. Package database Reconstruction

Rpm initdb: initialization. If no database exists, it is rebuilt. Otherwise, no operation is performed;

Rpm rebuilddb: re-create the database, whether it exists or not.

Iii. yum

Based on RPM package management, the RPM package can be automatically downloaded and installed from the specified yum source warehouse server. The dependency relationship can be automatically processed and all dependent software packages can be installed at a time. Yum provides commands for searching, installing, and deleting one or more software packages. Yum repository (yum repository) Stores many rpm packages and package-related metadata files (stored in a specific directory: repodata)

Yum client Configuration:

Configuration file:

/Etc/yum. conf: provides public configuration for all Repositories

/Etc/yum. repos. d/*. repo: Provides configuration information for warehouse pointing.

Available variables in the repo configuration file

$ Releasever: The main version of the current OS release;

$ Arch: Platform;

$ Basearch: Basic Platform (multiple platforms are recognized as one platform)

Repository definition:

[Repositoryid]

Name = somename For this repository

Baseurl = url: // path/to/repository # yum source repository address, which can be: ftp: //, http: //, ntf: //, file: /// etc.

Enabled = {1 | 0} # enable or not

Gpgcheck = {1 | 0} # Whether to perform Signature Verification

Gpgkey = URL # specify the key file

Enablegroups = {1 | 0}

Failovermethod = {roundrobin (random) | priority} # default: roundrobin, random round robin

Cost # overhead, 1000 by default

Create a yum Repository:

Yum createrepo [options] <directory>

Display the repository list:

Yum repolist [all | enabled | disabled]

Yum command usage:

Command Format: yum [options] [command] [package...]

Options:

Common installation, upgrade, and uninstallation options:

Repolist [all | enabled | disabled] # display the repository list

List [all | available | installed | updates} # display package

Installpackage1 [package2] [...] # Install the package

Reinstallpackage1 [package2] [...] # reinstall

Check-update # check for available upgrades

Update [package1] [package2] [...] # update a package

Remove | erase package1 [package2] [...] # uninstall the package

Info [package1] [package2] [...] # View package information

Downgradepackage1 [package2] [...] # downgrade

Provides | whatprovides feature1 [feature2] [...] # view which package provides the specified feature (which can be a file)

History [info | list | packages-info | summary] # view yum transaction history

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

Searchstring1 [string2] [...] # search for the package name and summary information with the specified keyword

Deplistpackage1 [package2] [...] # view the capabilities on which the specified package depends

Makecache # Build Cache

Localinstallrpmfile1 [rpmfile2] [...] # Install the local package

Localupdaterpmfile1 [rpmfile2] [...] # Upgrade the local package

Command for group management:

Groupinstall group1 [group2] [...] # Install a package Group

Groupupdate group1 [group2] [...] # update package Group

Grouplist [hidden] [groupwildcard] [...] # view the package group list

Groupremove group1 [group2] [...] # delete a group

Groupinfo group1 [...] # View package group information

Other options of YUM command line:

-- Nogpgcheck: Disable gpgcheck.

-Y: the automatic answer is yes.

-Q: silent mode

-- Disablerepo = repoidglob: temporarily disable the specified repo.

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

-- Noplugins: Disable all plug-ins;

Iv. Package compilation and Installation

Compiling C source code requires development tools, such as make and gcc (gnu c Complier), as well as development environments, such as development libraries, header files, and general standard libraries glibc. The package compilation and installation process is: source code --> preprocessing --> compilation (gcc) --> assembly --> Link (linker) --> execution

Three steps for compilation and installation:

1../configure

You can use autoconf to generate a configure script to pass parameters through options, specifying the feature, installation path, and referring to the user's designation and makefile during execution; and checking the dependent external environment;

Common options: Specify the installation location, and enable features. -- help can be used to obtain the supported options.

Installation path settings:

-- Prefix =/PATH/TO/SOMEWHERE: Specifies the default installation location

-- Sysdir =/PATH/TO/SOMEWHERE: Configuration File Installation PATH

Optional features: OptionalFeatures

-- Disable-FEATURE

2. make:

Build an application based on the makefile file. Use automake to generate Makefile. in.

3. make install

Install the data compiled in the previous step to the default directory.

Configuration after installation:

(1) Export the binary program directory to the path environment variable;

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

ExportPATH =/PATH/TO/BIN: $ PATH

(2) Export the outbound file path

Edit/etc/ld. so. conf. d/NAME. conf and add the directory where the new library file is located to this file;

Let the system regenerate the cache: ldconfig [-v]

(3) export the header file

Link-based implementation: ln-sv

(4) Export help manual

Edit the/etc/man. conf file and add a MANPATH

Obtain the source code of an open-source program:

Official self-built site

Apache.org

Mariadb.org

Code hosting:

SourceForge

Github.com

Code.google.com

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.