How to install rpm package

How to install rpm package

Установка rpm пакетов в Linux

Рано или поздно нам приходится устанавливать программное обеспечение не из официальных репозиториев. Там есть далеко не все пакеты, и не всегда есть самые новые версии, только что вышедших программ. Очень часто разработчики размещают на своем официальном сайте пакеты для самых популярных дистрибутивов. Обычно это deb и rpm.

Последний встречается немного реже, но если вы используете дистрибутив на базе Red Hat Enterprice Linux, вам нужен именно этот формат пакетов. Также в сети часто можно найти библиотеки и другие компоненты, которых нет в репозиториях в виде пакетов. Раньше мы уже рассматривали установку deb пакетов в Ubuntu. А в этой статье будет подробно разобрана установка rpm пакетов в linux.

Что такое RPM?

Установка RPM пакетов в Linux

Давайте сначала рассмотрим синтаксис самой утилиты rpm:

Утилита может работать в одном из режимов:

Рассмотрим только самые интересные опции программы, которые понадобятся нам в этой статье:

Теперь, когда вы уже имеете представление как работать с этой утилитой, может быть рассмотрена установка rpm пакета в Linux. Самая простая команда установки будет выглядеть вот так:

Для работы с командной текущей директорией должна быть папка с пакетом. Здесь мы устанавливаем режим установки и передаем файл пакета. При успешной установке утилита не выведет ничего, если произойдет ошибка, вы об этом узнаете.

Также вы можете включить отображение статус бара в процессе установки:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Чтобы проверить установлен ли пакет, нам уже нужно использовать режим запроса:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Также сразу можно удалить пакет, если он не нужен:

Но у rpm так же как и у dpkg, есть один существенный недостаток. Программа не может разрешать зависимости. В случае отсутствия нужного пакета в системе, вы просто получите сообщение об ошибке и пакет не установится.

Для автоматической загрузки зависимостей во время выполнения установки rpm linux нужно использовать пакетный менеджер дистрибутива. Рассмотрим несколько команд для самых популярных RPM дистрибутивов. В RedHat и других дистрибутивах, использующих Yum используйте такую команду:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Первая опция отключает проверку GPG ключа, а вторая говорит, что мы будем выполнять установку локального пакета. В Fedora, с помощью dnf все делается еще проще:

sudo dnf install имя_пакета.rpm

Пакетный менеджер Zypper и OpenSUSE справляются не хуже:

sudo zypper install имя_пакета.rpm

Вот так очень просто выполняется установка rpm с зависимостями. Но не всем нравится работать в консоли, многие новые пользователи хотят использовать графический интерфейс для решения всех задач, в том числе и этой. Дальше мы рассмотрим несколько таких утилит.

Установка RPM файла в GUI

Если вы используете OpenSUSE, то это делается очень просто. Универсальный конфигуратор системы YaST, кроме всего прочего позволяет установить rpm пакеты. Вы можете сделать это с помощью файлового менеджера, выбрав пункт контекстного меню для файла открыть с помощью Yast или выполнив команду:

В Fedora для тех же целей вы можете использовать менеджер приложений дистрибутива. Раньше было еще несколько универсальных утилит для решения этой задачи, но сейчас они уже все устарели.

Выводы

Теперь вы знаете как выполняется установка rpm файла в Linux. На самом деле это очень просто и даже существует не только один способ, а целых несколько. Хотя графических утилит здесь немного меньше чем в Ubuntu. Но консольных утилит полностью хватает. Если у вас остались вопросы, спрашивайте в комментариях!

How to install/remove/query/update RPM packages in Linux (Cheat Sheet)

Maintaining Software Using RPM (Red Hat Package Manager)

RPM is a powerful software manager which can be used to build, install, query, verify, update, and uninstall individual software packages. An RPM package consists of an archive of files, and package information such as name, version, a description and information about dependencies on other RPM packages.

RPM is more than a Red Hat specific tool. Many other modern distributions, such as Ubuntu and SuSE, use RPM too. Benefits of using RPM include:

RPM keeps information about installed packages under the “/var/lib/rpm” directory.

Components of the RPM tool are:

Types of RPM Packages

RPM packages come in two categories: source and binary.

A source RPM can always be recognized because the filename ends with the string “.src.rpm“. In a source RPM are not only the original program source code files but scripts that allow the code to be recompiled automatically, to be installed automatically, and to be removed automatically. There are no end-user executable files in a source RPM. Usually, only developers are interested in a source RPM.

A binary RPM contains the end-user compoments of an RPM. Binary RPM filenames identify the host architecture for the contents. For example, the binary RPM file:

It contains files only usable on a 64-bit Intel X86 architecture CPU. Other common architecture values include “i386” for 32-bit Intel hosts. Some binary RPM’s may be installed on any CPU architecture because their files will work on any host; an example of these “.noarch.rpm” packages is the “tzdata” RPM which contains information about world timezones. To update your system with the latest version of a package, you will need the most recent binary RPM for it.

RPM Naming Scheme

Each RPM package is contained in a single file. The filename has several fields to fully identify the contents of the package. While the RPM tools themselves do not rely upon the filename itself, you should understand the filename convention to help you identify or download the proper package. Here is an example RPM filename:

This RPM is for the BASH shell (“/bin/bash”). The filename is composed of several parts:

Understanding RPM Versions

The RPM [version] and [release] fields are not always strictly numeric and may contain other characters besides ordinary digits. It is common to see both a version “10” and a “10a” version of the same package. Sometimes picking the most recent version can be tricky. Here is how RPM itself compares version and release numbers internally:

1. Remove the [name] prefix and the “.[arch].rpm” suffix. For example,:
“bash-3.1-16.1.x86_64.rpm” becomes “3.1-16.1” and “bash-3.1-16.5a.1.x86_64.rpm” becomes “3.1-16.5a.1”

2. Compare the remaining strings character-by-character, left-to-right until a digit is encountered. If the characters differ, whichever character comes later in the collating sequence is the more recent RPM.

3. When a digit is encountered, convert the entire sequence of digits into a single binary number. In our example, the two characters “16” are combined into a value of sixteen (16). The resulting binary values are compared and the greater value is the more recent RPM. Thus, an RPM with a [version] of “0010” is more recent than one with a [version] of “9”.

Steps 2 and 3 are repeated as necessary until a difference occurs.

Installing and Removing Files

Later versions are usually installed using the “-U” (update) RPM function instead of the “-i” RPM function. Common exceptions to the only-one RPM rule are the kernel RPM’s. A system commonly has several versions of kernels installed; RPM has a list of which RPM’s may have multiple versions installed. To delete one version when several are installed, you must fully-specify the package name and version.

On the x86_64 architecture, it is common to have both the 32-bit “.i386” and the 64-bit “.x86_64” RPM packages installed tosupport both 32-bit and 64-bit applications. Normally, RPM does not display the architecture of a package on a query but you can manually display it.

Installation and Removal

Hint: Never, ever, use the “-U” option to install a new kernel RPM. The “-U” update function first deletes the current RPM from the system and then attempts to install the new RPM. Any problem that prevents the new RPM from installing will leave the system unbootable. This is not what you want, so always use the “-i” switch to install a kernel RPM.

Queries (Packages and/or Information)

Use a query for information about installed packages. You may query against all installed packages, or a single installed package. You may also find out which RPM supplies a particular file.

Information
default (package name)
-i: general information
-l: file list

Hint: When searching for a particular RPM package when the exact name is not known, a command pipeline such as:

is commonly used. Later versions of the RPM tool allow this to be succinctly done as:

Queries – Verification (Files)

The RPM database contains many attributes about each and every file installed by an RPM. You may verify the current status of the file against the information cataloged by RPM when the package was installed.

Adding this information does make applications start faster, but the file changes invalidate most of the file attributes in the RPM database, such as the last file modification date, file size, and the file’s MD5 checksum.

Queries – Verification (Packages)

Repair the RPM database

The RPM tool uses its own custom database implementation to contain its information. Sometimes that database can get corrupted; symptoms include claims that an installed RPM package is missing; or attempts to update an RPM simply hang. If your RPM database is hung or corrupted you can try to repair it with these commands. This process is not guaranteed to work.

You must be logged in with superuser privilege (aka “root”) for these steps. The commands may be copied and pasted directly into a root terminal window.

2. Delete the lock files that RPM uses:

3. If you were experiencing a hanging “rpm” command, try it again. If it works, you are finished. If not, perform Step #1 and #2 again. Then proceed to the next step.

How to Install an RPM File On Linux OS (CentOS, RHEL, & Fedora)

Home » SysAdmin » How to Install an RPM File On Linux OS (CentOS, RHEL, & Fedora)

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Note: RPM Package Manager (RPM) is a free and open-source package management system for installing, uninstalling and managing software packages in Linux.

Step 1: Download RPM Installation File

To install wget in CentOS, enter the following in a terminal window:

To install wget in Fedora, enter the following:

The system should reach out to the website and download the file to your current working directory.

Step 2: Install RPM File on Linux

Install RPM File Using RPM Command

The -i switch tells the package manager you want to install the file.

More information on the RPM installer can be found in the RPM documentation.

Install RPM File with Yum

Enter the following:

The localinstall option instructions yum to look at your current working directory for the installation file.

Note: YUM stands for Yellowdog Updater Modified. Normally, yum looks to your enabled software repositories for new software packages to install. More recent verbiage suggests using install instead of localinstall, but it’s up to you.

Install RPM on Fedora

Another method is to use the dnf utility to install the package:

Unlike many Linux tools, DNF is not a set of initials. It is merely the next evolution of the yum package manager.

Remove RPM Package

The RPM installer can be used to remove (or uninstall) a software package.

Enter the following into a terminal window:

The -e option instructs RPM to erase the software. Check RPM Dependencies

So far, this guide assumes the software either doesn’t have dependencies or already has them installed.

To check the .rpm file for dependencies using the following command:

The system should list all the dependencies:

If there are any missing dependencies, you can install them from the standard repositories using yum or dnf. If your software requires other non-standard software, it will often be noted in the installation instructions.

Download RPM Packages from the Repository

One exciting feature of the yum package manager is that it allows you to download .rpm files directly from the repository. This might be helpful if you have limited bandwidth, or want to copy a single downloaded file between systems. It could also help if you have intermittent internet access, and you don’t want to spend time waiting for your installer to finish.

To download a .rpm file from the repositories, enter the following:

If you wanted to download the files for Apache, for instance, you’d replace packagename with httpd. You can then install the file as above.

Note: In Linux, administrators find it helpful to have a single tool to manage software. That tool – called a package manager – can install software, keep track of software requirements, and track updates and patches. Package managers also work with repositories, which are secure and standardized libraries of commonly-used and well-supported applications. If you had to install wget in Step 1, that’s an example of installing from a repository.

In this tutorial, we covered three different options for installing RPM files on Linux.

As with most Linux software, your default package manager makes it simple to track installations, updates, and prerequisites.

How to Use the RPM Command in Linux

Home » SysAdmin » 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 install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Prerequisites

Linux RPM Command Syntax

The basic syntax for the command is:

To see a full list of command options, run:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

RPM Command Options

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

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:

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:

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

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

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:

To upgrade MySQL, use:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install 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:

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 :

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

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

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.

To do so for MySQL, run:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Display Package Information Before Installing

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

The command includes the options:

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

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

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:

The options are:

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

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:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install rpm package

Find Manual Pages

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

The command options are:

To find manual pages for MySQL, use the command:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install 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:

How to install rpm package. Смотреть фото How to install rpm package. Смотреть картинку How to install rpm package. Картинка про How to install rpm package. Фото How to install 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.

How to install or upgrade an RPM package?

Environment

Issue

Resolution

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.

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.

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:

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.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *