How to Download RPM Without Installing on RHEL 8 / CentOS 8

While working on RHEL and CentOS Servers there are some scenarios where we want to download specific or set of RPM packages from the command the line without installing it. Though we can use wget command to download packages but wget will not download package along with its dependencies.

On RHEL 8 or CentOS 8, DNF (or yum) is a command line package management utility. Using DNF or yum we can install, update and remove rpm packages. Apart from this it can also be used to download packages along with dependencies without installing them.

In this guide, we will cover how to download rpm packages without installing on RHEL 8 or CentOS 8 system.

Download Specific RPM Package

dnf or yum command on RHEL 8 or CentOS 8 has download flag which allows to download rpm package.

Syntax:

$ sudo dnf download <package-name>

Let’s assume, we want to download ‘nfs-utils’ package. Run

$ sudo dnf download nfs-utils

Above command will download the nfs-utils package in the present working directory. It will not download dependencies. Verify the downloaded package, run

$ ls
nfs-utils-2.3.3-26.el8.x86_64.rpm
$

Download RPM along with dependencies

Using ‘–downloadonly’ flag in dnf or yum command, rpm package along with its dependencies can be downloaded. We can also instruct dnf command to download rpm in particular folder using ‘–downloaddir’ flag.

Syntax:

$ sudo dnf install <package-name> –downloadonly –downloaddir <directory-path>

Let’s assume, we want to download ansible rpm along with its dependencies in package directory.

$ mkdir packages
$ sudo dnf install ansible --downloadonly --downloaddir ~/packages/

Download-RPM-Package-DNF-Command-RHEL

Once the above command is executed successfully, verify whether ansible rpm package is downloaded or not. Execute ls command,

$ ls -l packages/

Verify-Downloaded-RPM-Packages-ls-Command

Now we can make a tar file of these packages and transfer to a remote system where we want to install ansible and don’t have internet and repository connectivity on that system.

Download Group Package

Let’s suppose we want to download all the packages which comes under the group “Development Tools”, run beneath command.

$ sudo dnf group install "Development Tools" --downloadonly --downloaddir ~/dev-tools/ -y

Download-Development-tools-rhel-centos

Verify whether packages have been downloaded or not, run ls command

$ ls -l ~/dev-tools/

Verify-Group-Downloaded-Packages-ls-command

Great, above output confirms that all development packages have been downloaded under ~/dev-tools folder.

Note: Whenever we download packages with dnf  or yum command command and if we don’t pass –downloadidr flag then packages will be downloaded to ‘/var/cache/dnf/baseos-xxxx/packages/’, ‘/var/cache/dnf/appstream-xxxx/packages’ and ‘/var/cache/dnf/epel-xxxx/packages/’.

That’s all from this guide, I have found it informative. Kindly post your queries and feedback in below comments section.

9 thoughts on “How to Download RPM Without Installing on RHEL 8 / CentOS 8”

    • Hi ,

      you can use the rpm command to install samba packages. Go to the directory where you have downloaded the samba rpms and run the command :

      # rpm -ivh *.rpm

      OR You can also use yum command to install rpm

      #yum localinstall “*.rpm”

      Reply
  1. How to download all rpms of “rhel-7-server-optional-rpms” repository on our server which we can use offline?

    Reply
    • you must edit your repository to have just “rhel-7-server-optional-rpms” available, then you make and update/upgrade with redirection to a file and use download of yum command to parse that file.

      Reply
  2. how to download ntp using rpm, I tried above and download all the packages. still its failed due to
    :- “error: Failed dependencies:libcrypto.so.10(OPENSSL_1.0.2)(64bit)” Can anyone help me in this.

    Reply
    • Hi Akshay,

      Did you download ntp package along with its dependencies, if not then download those dependencies too. Example is shown below :
      # yumdownloader ntp –destdir /opt/downloaded_rpms –resolve

      Reply

Leave a Comment