Linux Package management tool (Rpm/dpkg,yum/apt,alien)

Source: Internet
Author: User
Tags gpg sha1

Summarized:

Rpm/yum Redhat

Dpkg/apt Debian

Alien Conversion

In the Gnu/linux (Linux) operating system, RPM and DPKG are the two most common types of package management tools that are applied to Linux distributions based on the RPM package and the DEB package. The role of the package management tool is to provide a way to install, upgrade, uninstall the required software in the operating system, and to provide queries on all software status information in the system.
RPM, known as Redhat package Manager, was first implemented by Red Hat and was subsequently accepted by the GNU open source operating system as a set of software standards for many Linux systems (RHEL). Competing with RPM is the Debian Package management tool-DPKG, all called Debian packages-that is similar in functionality to RPM. The specific comparison of the two is not within the scope of this article.

RPM Package Installation/upgrade/query/Uninstall
A RPM package contains the set of compressed software files and the content information of the software (saved in the header file), usually shown as files ending with the. RPM extension, such as package.rpm. You need to use the RPM command to manipulate it. The parameters and how to use the RPM tool are described below, and are described in the example of the installation of the IBM Lotus Notes in RHEL 5.2.
RPM Command Common parameters
RPM is the usual way to use RPM-? PACKAGE.RPM, which--? For action parameters (for more information, see Help $man rpm):
-Q Query the system for software or query the content information of the specified RPM package
-I install software in the system
-U upgrade software in the system
-e Uninstalling the software in the system
-H Displays the RPM installation process with the # (hash) character
-V detailing the installation process
-P indicates that the RPM packet is queried and is usually used in conjunction with other parameters, such as:
-QLP querying a list of all files in a RPM package
-QIP querying content information for a RPM package
How to use RPM command parameters
Some of the above parameters need to be combined, such as rpm-h package.rpm is meaningless, but rpm-ih package.rpm means to install the package and display the installation progress with the # symbol.
Installing RPM Packages

# RPM-IVH package.rpm
Upgrade RPM Package Command

# RPM-UVH package.rpm
Uninstall RPM Package Command

# Rpm-ev Package
Query the file List command included in the RPM package

# RPM-QLP Package
Query the file List command included in the RPM package

# RPM-QLP Package
Query the Content Information command included in the RPM package

# RPM-QIP Package
Querying all installed RPM packages in the system

# RPM-QA
RPM Package Management Example
The following steps describe a typical procedure for an ordinary user to install IBM Lotus Notes V85 (hereinafter referred to as Notes). The RPM package for Notes is named ibm_lotus_notes-8.5.i586.rpm.
First query whether the software already exists in the system
# Rpm-qa | grep ibm_lotus_notes
If the return information is empty then the software has not been installed.
Querying Notes Package Contents:
# RPM-QIP ibm_lotus_notes-8.5.i586.rpm

name:ibm_lotus_notes Relocations:/opt/ibm/lotu S/notes
version:8.5 vendor:ibm
release:20081211.1925 Build date:sat Dec 09:38:55 AM CST
Insta ll Date: (not installed) Build Host:dithers.notesdev.ibm.com
Group:applications/office
Source rpm:ibm_lotus_ notes-8.5-20081211.1925.src.rpm
size:603779427 license:commercial
Signature:dsa/sha1, Sat 2008 09:43 : AM CST, Key ID 314c8c6534f9ae75
summary:ibm Lotus Notes
Description:
IBM Lotus Notes software Provid Es a robust ...
Install Notes:
# RPM-IVH ibm_lotus_notes-8.5.i586.rpm
Return information:

Preparing ... ########################################### [100%]
1:ibm_lotus_notes ########################################### [100%]
Upgrade Notes:
If you need to upgrade to a later version of Notes (seam. 0-ibm_lotus_notes-9.0.i586.rpm) based on this version, use the-u parameter:
# RPM-UVH ibm_lotus_notes-8.5.i586.rpm
If you use-I in this step, the system will usually report a file conflict error that does not install properly.
Uninstalling Notes
Note The uninstall software uses the software name instead of the package file name:
# Rpm-ev Ibm_lotus_notes

Installation/upgrade/query/uninstallation of the DEB package
A DEB package contains the set of compressed software files and the content information of the software (saved in the header file), typically shown as files ending with a. DEB extension, such as Package.deb. You need to use the dpkg command to manipulate it. The parameters and how to use the Dpkg tool are described below, with an example of IBM Lotus Notes in UBUNTU 904 installation as a concrete illustration.
DPKG Command Common parameters
DPKG's general use method is DPKG-? Package (. rpm), where-? For installation parameters (for more information, see Help $man rpm):
-L query Software content information in the system
--info Query the system for software or query the content information of the specified RPM package
-I install/upgrade software in the system
-R uninstalling the software in the system without deleting the configuration file
-P uninstalling the software and its configuration files in the system
How to use the DPKG command parameter
Install the DEB Package command

$ sudo dpkg-i package.deb
Upgrade the DEB Package command

$ sudo dpkg-i package.deb (same as installation command)
Uninstalling the DEB Package command

$ sudo dpkg-r package.deb # do not unload the configuration file
Or
$ sudo dpkg-p package.deb # unload configuration file
Query the file list commands included in the DEB package

$ sudo dpkg-deb-c package.deb
Query the Content Information command contained in the DEB package

$ dpkg--info Package.deb
Querying all installed DEB packages in the system

$ dpkg-l Package
DEB Package Management Example
The following steps describe a typical operating procedure for an ordinary user to install IBM Lotus Notes V85 (hereinafter referred to as Notes). The DEB package for Notes is named Ibm_lotus_notes-8.5.i586.deb.
First, query whether the software is already present in the system
$ dpkg-l ibm-lotus-*
If the Lotus product has never been installed in the system, then the return information is:

No Pakcages found matching ibm-lotus-*
If the system has a Lotus product installed but has been deleted, the return information is:

PN Ibm-lotus-notes None (no description available)
Query the Notes Package contents:
$ dpkg--info Ibm_lotus_notes-8.5-i586.deb
Return information:

New Debian package, version 2.0.
Size 335012296 bytes:control archive= 231821 bytes.
...
Package:ibm-lotus-notes
version:8.5-20081211.1925
Section:ibm
Priority:extra
Architecture:i386
installed-size:619444
MAINTAINER:IBM Lotus Product
DESCRIPTION:IBM Lotus Notes
IBM Lotus Notes software provides a robust ...
To install Notes:
$ sudo dpkg-i ibm_lotus_notes-8.5.i586.deb
Return information:

(Reading database ... 151150 files and directories currently installed.)
Preparing to replace Ibm-lotus-notes 8.5-20081211.1925
(using Ibm-lotus-notes-higher-version.i586.deb) ...
Unpacking Replacement Ibm-lotus-notes ...

Setting up Ibm-lotus-notes (higher-version) ...
Upgrade Notes:
$ sudo dpkg-i ibm_lotus_notes-8.5.i586.deb
Return information:

(Reading database ... 151150 files and directories currently installed.)
Preparing to replace Ibm-lotus-notes 8.5-20081211.1925
(using Ibm-lotus-notes-higher-version.i586.deb) ...
Unpacking Replacement Ibm-lotus-notes ...

Setting up Ibm-lotus-notes (higher-version) ...
Uninstalling Notes
Note The uninstall software uses the software name instead of the package file name:
$ sudo dpkg-p ibm-lotus-notes

Package Dependency Relationships
Due to the polymorphism of open source, the dependency relationship between software in Linux operating system has always been a headache for users. If Package_a relies on Package_b, in a system that does not have Package_b installed, Package_a is not recommended by the system, and forcing the installation is likely to cause the software to not work properly. Based on the relationship between Package_a and Package_b above, in a clean system (PACKAGE_A or Package_b not installed), to install package_a, the error usually appears as:
RHEL 5.2

# RPM-IVH package_a.rpm

error:failed dependencies:
Pacakge_b = version info is needed by package_a
Ubuntu 904

$ sudo dpkg-i package_a.deb

Dpkg:regarding Package_a.deb containing package, pre-dependency PROBLM:
Package_a pre-depends on Package_b (version info)
Dpkg:error processing Package_a.deb (--install):
Pre-dependency Problem-not Installing Package_a
Errors were encountered while processing:
Package_a.deb
Querying package dependencies
To query the dependency of the RPM package, use RPM-QRP:

# RPM-QRP package_a.rpm

Package_b = Version_info
Or
Package_b >= Version_info
Or
Package_b <= Version_info
Indicates that package_a.rpm relies on the version_info version of Package_b, or any package_b that is above and including Version_info version, or below or including Version_info version. So package_b.rpm must be installed in the system before package_a.
Query the dependencies of the DEB package to interpret the Pre-depends fields in the dpkg--info results:

$ dpkg--info Package_a.deb

Pre-depends:package_b (= version_info)
Depends:package_b (= version_info)
Or
Pre-depends:package_b (>= version_info)
Depends:package_b (>= version_info)
Or
Pre-depends:package_b (<= version_info)
Depends:package_b (<= version_info)
Indicates that Package_a.deb relies on the version_info version of Package_b or any package_b that is above and including Version_info version, or below or includes Version_info version. So P Ackage_b.deb must be installed in the system prior to package_a.
So the correct installation method is shown in the following section.
Installation method
For package_a, the correct installation method should be:

# #RPM
# RPM-IVH package_b.rpm
# RPM-IVH package_a.rpm

# #DEB
$ sudo dpkg-i package_b.deb
$ sudo dpkg-i package_a.deb
Nested dependencies
As the above example is the most ideal dependency, the actual application often the most user headache is package_a dependent on package_b/c/d/e/f and other packages, and package_b/c/d/e/f and other packages depend on package_b1,b2,b3/c1,c2/ D1,d2/e1,e2/f1,f2 and so on ... To ensure the proper use of the software, all dependent packages and child dependent packages must be found and installed. Excessive dependencies greatly reduce the user-friendliness of Linux software installations. So for this kind of problem, the more advanced package management strategy is used to solve-yum/apt.

More friendly package management software-YUM
YUM
Based on the RPM Package management tool, YUM can automatically download the target RPM package from the specified source space (server, local directory, etc.) and install it, automatically handle dependency relationships and download, install, without tedious manual download and installation of each required dependency package. In addition, another feature of YUM is to upgrade all software in the system. As mentioned above, the YUM RPM package is derived from the source space, specified in RHEL by the. Repo file configuration in the/etc/yum.repos.d/directory, such as the contents of Rhel-debuginfo.repo:
Rhel-debuginfo.repo

[Rhel-debuginfo]
name=red Hat Enterprise Linux 5client-i386-debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5client/en/os/i386/debuginfo/
Enabled=0
Gpgcheck=1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-redhat-release
YUM's system configuration file is located in/etc/yum.conf, as follows:

[Main]
Cachedir=/var/cache/yum
Keepcache=1
debuglevel=2
Pkgpolicy=newest
Logfile=/var/log/yum.log
Distroverpkg=redhat-release
Tolerant=1
Exactarch=1
Obsoletes=1
Gpgcheck=1
Plugins=1
Exclude= Firefox gftp
Configuration files are used to define the yum behavior that users expect, such as Gpgcheck? Indicates that no GPG verification is performed during installation, and Exclued=firefox gftp indicates that Firefox and Gftp are not upgraded when the system is fully software upgraded.
YUM Common Commands
To install the specified software:

# yum-y Install Package-name
List installed software on the system

# Yum List
List all software that can be upgraded in the system

# yum Check-update
Upgrade all software that can be upgraded in the system

# Yum Update
Upgrade specified software

# Yum Update Package-name
Receive all interactive questions during the upgrade process

# yum-y Update
Uninstalling the specified software

# yum Remove Package-name
For more information on YUM, please refer to Http://fedoraproject.org/wiki/Tools/yum.

More friendly package management software-APT
Apt
APT is all called Advanced packaging Tools. corresponding to YUM, it was first designed as a DPKG front-end software and now supports RPM management through apt-rpm. This section will introduce the use of APT as the DPKG front end. APT's main package management tool is apt-get, which satisfies the functionality requirements similar to the above YUM.
APT's software source definition is from the/etc/apt/sources.list file:

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# Newer versions of the distribution.

Deb Http://cn.archive.ubuntu.com/ubuntu/hardy main restricted
DEB-SRC Http://cn.archive.ubuntu.com/ubuntu/hardy Main restricted
Note Each time you manually modify the above file, you need to use sudo apt-get update to update the source of the system so that the new source data is recognized by the current system.
The APT configuration file in UBUNTU is located in/etc/apt/apt.conf.d, where multiple profiles are categorized by function.
APT Common Commands
Update Source Index

$ sudo apt-get update
Installing the specified software

$ sudo apt-get install Package-name
Download the source file for the specified software

$ sudo apt-get source Package-name
Upgrade all software in the system to the latest version

$ sudo apt-get upgrade
Upgrade the operating system with all software to the latest version

$ sudo apt-get dist-upgrade
Uninstalling the specified software

$ sudo apt-get remove package-name
For more information about APT, please refer to http://www.debian.org/doc/manuals/apt-howto/index.en.html.
Back to top of page
RPM compatible with DEB-Alien
The Alien tool can be used to convert RPM packages into Deb packages or to convert the Deb package into an RPM package to accommodate compatibility needs. Note First, install alien in the system.
Use Alien in UBUNTU to convert RPM to Deb and install:

$ sudo alien-d package.rpm
$ sudo dpkg-i package.deb
Use Alien in RHEL to convert Deb to rpm and install:

# Alien-r Package.deb
# RPM-IVH package.rpm
For more information about Alien, please refer to Http://linux.die.net/man/1/alien

Summary
Taking RHEL 5.2 and Ubuntu 904 as examples, this paper introduces two common software package management tools-RPM and DPKG based on command line operation. First of all, from the bottom of the rpm/dpkg command operation began to enumerate their basic use, and then pointed out the dependencies of the software and the resulting problems, and the solution to this problem, but also the most popular YUM and APT front-end software management system to operate the introduction. Finally, this paper briefly describes the current Rpm/deb compatibility problem of the general solution.

FAQ List
Can I manually force a dependency check without Rpm/deb?
Rpm
OK. With the--nodeps auxiliary parameter, the installation process ignores dependency constraints and forces the installation of the target package, such as:
# rpm-i--nodeps package_a.rpm
Deb
OK. Use-force-depends auxiliary parameters, such as:
$ sudo dpkg-i--force-depends package_a.deb
What does the--force in RPM do?
The default installation rule in RPM is that the same package is not allowed to be installed multiple times, and the installation is not allowed to downgrade. Using the--force auxiliary parameter will not take into account the above factors, forcing the installation of RPM packages. However,--force cannot force the installation of a package that does not satisfy the system dependency relationship (the--nodeps parameter is required at this time). Use methods such as:
# rpm-i--force package_a.rpm
Does rpm/dpkg support remote installation?
Rpm
Is. RPM supports HTTP and FTP protocols, such as:
# RPM-UVH Ftp://user:[email protected]/package.rpm
DPKG
In the latest DEB package-based systems, remote installations are often replaced by more advanced APT.
Can I extract individual files from the rpm/dpkg?
Rpm
Is. You can use the Rpm2cpio tool to extract files: http://www.rpm.org/max-rpm/s1-rpm-miscellania-rpm2cpio.html
DPKG
Is. You can use the Dpkg-deb tool to extract files:
$ dpkg-deb--extract ibm_lotus_notes-8.5.i586.deb $dir (target directory)
Does rpm/dpkg provide a validation mechanism for package installation success?
Rpm
Is. You can use the-v parameter for validation.
DPKG
Debian systems are typically validated using Debsums tool parameters.
Does rpm/dpkg provide package security signatures?
Rpm
Is. You can use--import to import GPG keys that are released concurrently with the software, and then use the-K command to verify the security of the package, such as:
# rpm--import PUB_IBM_LOTUS_NOTES.GPG # rpm-k ibm_lotus_notes-8.5.i586.rpm return information: ibm_lotus_notes-8.5.i586.rpm: (SHA1) d SA SHA1 MD5 GPG OK
DPKG
DPKG does not provide a native Key validation mechanism. You can use Debsigs and debsigs-verify for details, see: http://man.ddvip.com/os/debiansecuring-howto/ch7.zh-cn.html
Can rpm be used if the underlying database of RPM is corrupted?
Rpm
RPM will not work properly if the underlying database is damaged. The most common workaround at this point is to refactor the database:
# rm-f/var/lib/rpm/__*; RPM-VV--REBUILDDB
Rpm
The DPKG itself does not provide the underlying database recovery mechanism. Its database is stored as a file in the/var/lib/dpkg directory. Backing up this directory in a timely manner is the best precaution against database corruption.
Can you query which RPM package is part of a file that is already installed on the system?
Rpm
OK. Use the-QF parameter, as in a system with Notes8.5 installed:
# rpm-qf/opt/ibm/lotus/notes/notes return information: ibm_lotus_notes-8.5-20081211.1920
DPKG
OK. Use the-search parameter, as in a system with Notes8.5 installed:
$ dpkg--search/opt/ibm/lotus/notes/notes return information: ibm-lotus-notes:/opt/ibm/lotus/notes/notes
Can I check the installation time of RPM packages?
Rpm
OK. You can use--last queries. Such as:
RPM-QA--last return information: The installation time of all software in the system.
DPKG
DPKG does not provide direct query parameters, but can be used to query the DPKG log file to achieve this function. Such as:
Cat/var/log/dpkg.log | grep "\ install\"

Linux Package management tool (Rpm/dpkg,yum/apt,alien)

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.