Centos yum only download package Not Installed
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 itself can be used to download an RPM package. The standard yum command provides the-downloadonly option to achieve this purpose.
$ 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) to use the-downloadonly Command Option:
$ 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 201568175145007.jpg (800×459)
Method 2: Yumdownloader
Another method for downloading the RPM package is to download the package through 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.