Download rpm packages in linux

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.

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:

To see a full list of command options, run:

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:

The command includes the options:

  • -i (install)
  • -v (verbose output)
  • -h (print hash marks to show the installation process)

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:

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:

  • -U (upgrade)
  • -v (verbose mode)
  • -h (print hash marks to show upgrading process)

To upgrade MySQL, use:

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

Читайте также:  Linux локальный сервер для разработки

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:

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:

Display Package Information Before Installing

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

The command includes the options:

  • -qi (query information)
  • -p (query/verify a package)

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

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:

  • -q (query format)
  • -p (query/verify a package)
  • -R (list package dependencies)

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:

  • -V (verify)
  • -a (all)

To verify a specific package run:

  • -V (verify)
  • -p (package)

Verify the installed MySQL package with:

Find Manual Pages

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

The command options are:

  • -q (query format)
  • -d (list documentation files)
  • -f (query package owning file)

To find manual pages for MySQL, use the command:

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:

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 an RPM File On Linux OS (CentOS, RHEL, & Fedora)

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

While working in Linux, you may have seen downloadable files with the .rpm extension. Rpm files are designed to be downloaded and installed independently, outside of a software repository.

Читайте также:  Астрономические ошибки что это

This guide will show you how to install a .rpm file to your Linux CentOS or Fedora system.

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

  • A user account with sudo privileges
  • Access to a terminal window / command line (Menu > applications > utilities > terminal, Ctrl-Alt-F2)
  • RPM, DNF, & YUM Package Managers (all included by default)

Step 1: Download RPM Installation File

Typically, a web browser is used to locate and download a .rpm file. However, if a browser is not available you can still download a file if you know where it’s located.

You may need to install a software tool called wget .

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

To install wget in Fedora, enter the following:

Now, you can use the wget command to download the .rpm file you want. Enter the following:

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

Note: You can look up the address of a particular .rpm file in a web browser on another system. Also, this is a handy way to install more recent software versions or special non-standard software. Also, take care when installing software packages! Make sure you trust the source before you install. Usually, a developer will include a verification method to make sure you’re getting authentic software.

Step 2: Install RPM File on Linux

Install RPM File Using RPM Command

To install a .rpm package in CentOS Linux, enter the following:

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

Alternately, you can use the yum package manager to install .rpm files.

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

To install an .rpm package on Fedora Linux, enter the following:

Just as in CentOS, the -i switch tells RPM to install the software.

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:

  • -q – This option tells RPM to query the file
  • -p – This option lets you specify the target package to query
  • -R – This lists the requirements for the package

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.

Источник

📦 Как скачать RPM пакетов без установки в системах Linux

При работе на серверах RHEL и CentOS возникают ситуации, когда мы хотим загрузить определенный пакет или набор пакетов RPM из командной строки без его установки.

Хотя мы можем использовать команду wget для загрузки пакетов, но wget не загрузит пакет вместе с его зависимостями.

В RHEL 8 или CentOS 8 DNF (или yum) – это утилита управления пакетами из командной строки.

С помощью DNF или yum мы можем устанавливать, обновлять и удалять пакеты rpm.

Кроме того, его можно использовать для загрузки пакетов вместе с зависимостями без их установки.

В этом руководстве мы рассмотрим, как загрузить пакеты rpm без установки в системе RHEL 8 или CentOS 8.

Загрузка определенного пакета RPM

Команда dnf или yum в RHEL 8 или CentOS 8 имеет флаг download, который позволяет загрузить пакет rpm.

$ sudo dnf download .

Предположим, мы хотим загрузить пакет ‘nfs-utils’. Запустите

Вышеприведенная команда загрузит пакет nfs-utils в текущий рабочий каталог. Она не будет загружать зависимости.

Чтобы проверить загруженный пакет, выполните

Загрузка RPM вместе с зависимостями

Используя флаг ‘-downloadonly’ в команде dnf или yum, можно загрузить пакет rpm вместе с его зависимостями.

Мы также можем указать команде dnf загрузить rpm в определенную папку с помощью флага ‘-downloaddir’.

$ sudo dnf install -downloadonly -downloaddir .

Предположим, мы хотим загрузить ansible rpm вместе с его зависимостями в каталог package.

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

Теперь мы можем сделать tar-файл этих пакетов и перенести его на удаленную систему, где мы хотим установить ansible, но на этой системе нет интернета и подключения к хранилищу.

Загрузка группового пакета

Допустим, мы хотим загрузить все пакеты, входящие в группу ““Development Tools”, выполните команду:

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

Примечание: Всякий раз, когда мы загружаем пакеты с помощью команд dnf или yum и если мы не передаем флаг -downloadidr, пакеты будут загружены в ‘/var/cache/dnf/baseos-xxxx/packages/’, ‘/var/cache/dnf/appstream-xxxx/packages’ и ‘/var/cache/dnf/epel-xxxx/packages/’.

Пожалуйста, оставляйте свои вопросы и отзывы в разделе комментариев ниже.

Источник

Поделиться с друзьями
КомпСовет
Adblock
detector