Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to download the RPM package without installing it with the yum command in CentOS

Shulou Source: shulou.com Published: 2022-06-01 08:06:03 10月02日 Update

This article introduces the knowledge of "how to download RPM package without installing it with yum command in CentOS". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Yum is the default package manager on Red Hat-based systems such as CentOS, Fedora, RHEl. With yum, you can install or update a RPM package, and it will automatically resolve package dependencies. But what if you just want to download a RPM package to your system? For example, you may want to get some RPM packages for later use, or install them on another machine.

Here is how to download a RPM package from the yum repository.

Method 1: yum

The yum command itself can be used to download a RPM package, and the standard yum command provides the option-- downloadonly (download only) to do this.

The code is as follows:

$sudo yum install-downloadonly

By default, a downloaded RPM package is saved in the following directory:

The code is as follows:

/ var/cache/yum/x86_64/ [centos / fedora-version] / [repository] / packages

The [repository] above indicates the name of the source repository where the package was downloaded (for example: base, fedora, updates)

If you want to download a package to a specified directory (such as / tmp):

The code is as follows:

$sudo yum install-downloadonly-downloaddir=/tmp

Note that if the downloaded package contains any unsatisfied dependencies, yum will download all dependency packages, but none of them will be installed.

Another important thing is that in CentOS/RHEL 6 or earlier, you need to install a separate yum plug-in (named yum-plugin-downloadonly) to use the-- downloadonly command option:

The code is as follows:

$sudo yum install yum-plugin-downloadonly

Without the plug-in, you will get the following error when using yum:

The code is as follows:

Command line error: no such option:-- downloadonly

Method 2: Yumdownloader

Another way to download RPM packages is through a special package download tool, yumdownloader. This tool is a subset of the yum toolkit, which contains a suite of help tools for managing yum packages.

The code is as follows:

$sudo yum install yum-utils

Download a RPM package:

The code is as follows:

$sudo yumdownloader

The downloaded package is saved in the current directory. You need to use root permissions because yumdownloader updates the package index file during the download process. Unlike the yum command, any dependent packages will not be downloaded.

This is the end of "how to download the RPM package without installing it with the yum command in CentOS". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Code commands tools methods catalogs usage warehouses content names situations plug-ins more knowledge systems processes updates management different practical important Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Apple Huawei MySQL NVidia