# LPI Linux Certification/Use RPM and YUM package management

Red Hat Package Manager is a powerful package manager, which can be used to build, install, query, verify, update, and erase individual software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.

## Detailed Objective

(LPIC-1 Version 5.0)
Weight: 3
Description:
Candidates should be able to perform package management using RPM, YUM and Zypper.
Key Knowledge Areas:
* Install, re-install, upgrade and remove packages using RPM, YUM and Zypper.
* Obtain information on RPM packages such as version, status, dependencies, integrity and signatures.
* Determine what files a package provides, as well as find which package a specific file comes from.
* Awareness of dnf.
The following is a partial list of the used files, terms and utilities:
* rpm
* rpm2cpio
* /etc/yum.conf
* /etc/yum.repos.d/
* yum
* zypper

## Red Hat Package Manager

Some Linux distribution uses rpm the “Red Hat Package Manager” for all its distribution software. RPM maintains a detailed database of all software installed in the system.
To install a RPM package, do:
The package will be installed only if the dependency are met and there is no conflict with another package. To upgrade a package, do:
The files of the old package version will be removed and replaced by the new files. To remove a RPM package, do:
The package will be removed only if no other package depends on it.

## RPM Queries

With the -q option you can query the RPM database or display information about package file.
There are several switches that you can use:
* -i: to get package information
* -l: To get a file list of a package.
* -f file: Query which package a file belongs to.
* -s: File list with status information.
* -d: list only documentation files.
* -a: List all the installed packages.
If you want to display information about package file you can specify filename using -p switch:

## RPM Commands

To get general information on a package or program, use rpmlocate.
Searching for ipcs in rpm db:
To list all the installed packages, use rpmqpack:
Alternatively use:

## Source Installation

The RPM source files have generally the format package.src.rpm and can be installed the same way as binaries. The directories where they will be installed from /usr/src/packages are:
* SOURCES: For the original sources.
* SPECS: For the .spec file that controls the build process.
* BUILD: All the sources are built in this directory.
* RPMS: Where the complete binary packages are stored.
* SRPMS: The sources.
To install the source of a package, do:
The source files will be stored in the /usr/src/packages in directories SPEC and SOURCES. To compile the sources, do:
The result of the compilation will be stored in the BUILD directory

## Exercises

* Exercises results
* Is the apache package installed?
* In which package are the files /bin/ls, /usr/sbin/tcpdump, and /sbin/ifconfig?
* From the floppy disk install the pci utilities and grub packages. Build the binaries and try to execute them. The sources should be in the /usr/src/packages/BINARY directory.