Getting started with Linux: Use yum to download the RPM package without installing it
Q: I want to download an RPM package from the standard repository of Red Hat. Can I use the yum command to download an RPM package without installing it?
Yum is the default Package Manager based on Red Hat systems (such as CentOS, Fedora, and RHEl. With yum, you can install or update an RPM package, and it automatically resolves the package dependency. But what if you only want to download an RPM package to your system? For example, you may want to get some RPM packages for later use or install them on another machine.
The following explains how to download an RPM package from the yum repository.
Method 1: yum
The yum command can be used to download an RPM package. The standard yum command provides-- Downloadonly (download only)
To achieve this goal.
$ sudo yum install --downloadonly <package-name>
By default, a downloaded RPM package is saved in the following directory:
/var/cache/yum/x86_64/[centos/fedora-version]/[repository]/packages
The above [repository] indicates the name of the source warehouse of the downloaded package (for example, base, fedora, updates)
If you want to download a package to a specified directory (such as/tmp ):
$ sudo yum install --downloadonly --downloaddir=/tmp <package-name>
Note: If the downloaded package contains any dependency that is not met, yum will download all dependency packages, but will not be installed.
Another important thing is that in CentOS/RHEL 6 or later versions, you need to install a separate yum plug-in (named yum-plugin-downloadonly ).--downloadonly
Command Options:
$ sudo yum install yum-plugin-downloadonly
If this plug-in is not available, you will get the following error when using yum:
Command line error:no such option:--downloadonly
Method 2: Yumdownloader
Another method for downloading an RPM package is to use a dedicated package download tool, yumdownloader. This tool is a subset of the yum Toolkit (including the help toolkit for yum package management.
$ sudo yum install yum-utils
Download an RPM package:
$ sudo yumdownloader <package-name>
The downloaded package is saved in the current directory. You need to use the root permission, because yumdownloader will update the package index file during the download process. Unlike the yum command, no dependent package will be downloaded.
How to Set DVD as the default yum source in CentOS
RedHat 6.2 modify yum source in Linux use CentOS source for free
Configure the epel yum Source
Redhat local yum source configuration
Description of yum configuration file
Install yum in RedHat 6.1)
YUM installation and cleaning
Build yum local source on CentOS 6.4
This article permanently updates the link address: