Installing an rpm package in linux

How to install or upgrade an RPM package?

In order to install an RPM package you must first have the RPM package you are trying to install on your system. The Red Hat Customer Portal provides all the RPM packages included in our products in our Downloads area. There are two ways to locate a package you are interested in.

Browse by Package name
From Downloads, choose RPM Package Search. The Package Search allows searching for packages regardless of product, but can be limited to a specific product.

Browse By Product
From Downloads, browse to the product you are interested in and then select the ‘Packages’ tab. For example, packages for RHEL 7 Server

Note: An active product subscription that includes entitlements to the package are required to view or download packages.

For more information about downloading packages from the Customer Portal see this solution: How to download rpm package manually from the Customer Portal?

Installing or Upgrading

There are two main options of rpm command that are used to install or upgrade RPM packages:

  • -i is used to install a new package. Always use this for kernel installations and upgrades just in case.
  • -U is used to upgrade an RPM package but will also install a package if it does not exist in the RPM database.

Usage and additional options can be found in the RPM man page. Type man rpm from the command line. Here is some information about the -i and -U flags:

INSTALL AND UPGRADE OPTIONS The general form of an rpm install command is rpm <-i|--install>[install-options] PACKAGE_FILE . This installs a new package. The general form of an rpm upgrade command is rpm <-U|--upgrade>[install-options] PACKAGE_FILE . This install the package or upgrades the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed. 

Note: These examples assume the packages are in a directory on your system. The below RPM commands are executed in the current working directory where the new RPM files reside.

  • To install an RPM package, we use of the -i flag. As mentioned before, you use this flag when you are installing a kernel RPM. In this case, you will want to leave your old kernel in place, at least temporarily, in case the new kernel does not boot. In this example, we first check to see the names of the new RPM packages with the ls command. Then we query the RPM database to see which kernel packages are already installed. You do not need to include the version number in the query, but the usage is: rpm -q . We can install the RPM package with the following command: rpm -ivh . Note the -v option will show verbose output and the -h will show the hash marks, which represents action of the progress of the RPM upgrade. Lastly, we run another RPM query to verify the package will be available.
# ls kernel-2.4.21-15.0.3.EL.i686.rpm kernel-smp-2.4.21-15.0.3.EL.i686.rpm # rpm -q kernel; rpm -q kernel-smp kernel-2.4.21-4.0.1.EL kernel-2.4.21-15.0.2.EL kernel-smp-2.4.21-4.0.1.EL kernel-smp-2.4.21-15.0.2.EL # rpm -ivh kernel-2.4.21-15.0.3.EL.i686.rpm Preparing. ########################################### [100%] 1:kernel ########################################### [100%] # rpm -ivh kernel-smp-2.4.21-15.0.3.EL.i686.rpm Preparing. ########################################### [100%] 1:kernel-smp ########################################### [100%] # rpm -q kernel; rpm -q kernel-smp kernel-2.4.21-4.0.1.EL kernel-2.4.21-15.0.2.EL kernel-2.4.21-15.0.3.EL kernel-smp-2.4.21-4.0.1.EL kernel-smp-2.4.21-15.0.2.EL kernel-smp-2.4.21-15.0.3.EL 
  • To upgrade an RPM package, we use of the -U flag. In this example, we verify the new package name with the ls command. Then we will run an RPM query to see if the package we want to install exists in the RPM database, rpm -q . Next, we execute the RPM installation with the following command: rpm -Uvh . Note the -v option will show verbose output and the -h will show the hash marks, which represents action of the progress of the RPM upgrade. Lastly, we run another RPM query to verify the package will be available.
# ls httpd-2.0.46-32.ent.3.i386.rpm mod_ssl-2.0.46-32.ent.3.i386.rpm # rpm -q httpd; rpm -q mod_ssl httpd-2.0.46-32.ent mod_ssl-2.0.46-32.ent # rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm mod_ssl-2.0.46-32.ent.3.i386.rpm Preparing. ########################################### [100%] 1:httpd ########################################### [ 50%] 2:mod_ssl ########################################### [100%] # rpm -q httpd; rpm -q mod_ssl httpd-2.0.46-32.ent.3 mod_ssl-2.0.46-32.ent.3 

Note: The httpd and mod_ssl needed to be installed at the same time because of dependency issues. If you try to install one without the other, you would get an error similar to the following:

# rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm error: Failed dependencies: httpd = 2.0.46-32.ent is needed by (installed) mod_ssl-2.0.46-32.ent 

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Источник

How to Use the RPM Command in Linux

RPM is a command-line utility for managing packages on Unix/Linux systems. It allows you to install, query, update, verify and remove RPM packages.

It is the default package manager for Red Hat based systems and only works with the .rpm format. You can install such packages using the rpm or the yum command.

In this article, you will learn how to use rpm commands with easy-to-follow examples.

How to use the RPM command in Linux.

Prerequisites

  • A system running Linux.
  • Access to the command line/terminal.
  • Access to root or an account with sudo privileges.

Linux RPM Command Syntax

The basic syntax for the command is:

sudo rpm [option] [package_name]

To see a full list of command options, run:

Display RPM command help message.

RPM Command Options

Below you will find the most popular command options used with the rpm command and their meaning.

-e , —erase Remove (uninstall) package(s).
-h , —hash Print hash marks as the package installs.
-i , —install Install package(s).
-l , —list List files in a package.
-q , —query Query package(s).
-s , —state Display the state of the listed files.
-U , —upgrade Upgrade package(s).
-v , —verbose Provide more detailed output.
-V , —verify Verify package(s).

RPM Command Examples

The rpm command is simple to use and allows combining multiple options to customize each query. Explore some of the most commonly used commands listed below and try out how they work with a sample package.

Install RPM Packages

To install RPM packages with the rpm command, use the syntax:

sudo rpm -ivh package_name

The command includes the options:

Before installing, you need to download the appropriate file. The package has to be compatible with the system architecture of the machine.

Note: To download packages, use the curl or wget command.

For instance, to install the MySQL package, you run:

sudo rpm -ivh mysql80-community-release-el7-5.noarch.rpm

To install an RPM package without previously downloading it, provide the URL:

sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm

Install an RPM package without previously downloading it.

Note: For a more detailed guide on installing RPM packages, check out our guide on how to install RPM packages on Ubuntu.

Upgrade RPM Packages

RPM upgrades a package by uninstalling the current version and installing the latest one.

The command for upgrading a package is:

sudo rpm -Uvh package_name
  • -U (upgrade)
  • -v (verbose mode)
  • -h (print hash marks to show upgrading process)
sudo rpm -Uvh mysql80-community-release-el7-5.noarch.rpm

Upgrade RPM package.

If the new version requires additional dependencies, you must install them manually. RPM lists the missing dependencies in the output after running the command.

To ignore the message and update without the dependencies, add the —nodeps option to the command:

sudo rpm -Uvh --nodeps package_name

Remove RPM Packages

Remove RPM packages using the -e ( —erase ) option:

To see the verbose output, add the -v option to the command:

To delete an RPM package without removing dependencies, add —nodeps :

sudo rpm -ev --nodeps package_name

For example, to remove MySQL without removing its dependencies, you run:

sudo rpm -ev --nodeps mysql80-community-release-el7-5.noarch

Delete an RPM package without removing its dependencies.

Note: For a more detailed guide on removing RPM packages, check out our guide on how to remove packages in CentOS.

Display Package Information After Installing

To see available information about an installed RPM package, use the -qi option, which instructs RPM to query info :

The output displays the installed information, package version, and a short description.

sudo rpm -qi mysql89-community-release-el7-5.noarch

Display package information after installing.

Display Package Information Before Installing

The command for displaying information about a package prior to installation is:

sudo rpm -qip package_name

The command includes the options:

To display information before installing the MySQL package, use the command:

sudo rpm -qip mysql89-community-release-el7-5.noarch

Check Package Dependencies Before Installing

RPM allows you to check the dependencies of packages prior to installing them on the system. Bear in mind, you need to have the RPM package downloaded locally to see a list of dependencies.

The command for doing so is:

For example, to list the dependencies for installing the MySQL RPM package, you run:

rpm -qpR mysql80-community-release-el7-5.noarch

Verify Packages

Verifying packages means comparing metadata from the RPM database with the information from the installed files.

You can verify all installed packages using the command:

To verify a specific package run:

Verify the installed MySQL package with:

sudo rpm -Vp mysql80-community-release-el7-5.noarch.rpm

Verify RPM package.

Find Manual Pages

To list available documentation related to an installed RPM package, use the -qdf option:

sudo rpm -qdf package_name

To find manual pages for MySQL, use the command:

sudo rpm -qdf mysql80-comunity-release-el7-5.noarch.rpm

List available documentation related to an installed RPM package.

List All Files of an Installed Package

See detailed information about a package by listing all its files, use the -ql option and instructs RPM to query list :

For example, to list files of the sample MySQL package, you run:

sudo rpm -ql mysql80-community-release-el7-5.noarch

List all files of an installed RPM package.

List Installed Packages

List all of the installed RPM packages on the system by running the following:

The command includes the -qa option, which instructs RPM to query all.

List Recently Installed Packages

To display a list of all the recently installed packages, use the -qa (query all) option along with the —last attribute:

The output lists all the installed RPM packages, ordering them by the latest package on top.

Where to Find and Download RPM Packages?

You can find and download RPM packages on the following websites:

In this article, you learned how to use the rpm command for installing, verifying, upgrading, and deleting packages. Still, it is recommended to use the yum or dnf command for such actions as they automatically deal with dependencies.

Источник

Читайте также:  Linux посмотреть версию установленного пакета
Оцените статью
Adblock
detector