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.

The post How to Download RPM Without Installing on RHEL 8 / CentOS 8 first appeared on LinuxTechi.

Leave a Comment