We can use package managers to download only rpm packages(offline) without installing them with all dependencies on Linux.
You can use downloaded rpm to install the package on another system that doesn't have internet. Also in scenarios where you used curl or wget to download a package but the required dependencies missing. Then also this comes to help.
DNF package manager is used in RedHat-based distributions such as RHEL, CentOS, and Fedora, mostly for installation, reinstallation, update, upgrade, and removal of rpm packages.
In this guide, we learn how to download RPM using DNF without installing it.
Downloading RPM using dnf
On Fedora 22 and later, yum is deprecated and in its place is the dnf package manager.
To download a package using dnf, use the following syntax:
dnf download package-name
To enhance DNF with download, this will install core plugins. List installed packages to check if its already installed.
dnf install dnf-plugins-core
For example to download the samba package, type:
dnf download samba
To download the dependencies, append the --resolve flag
dnf download samba --resolve
Check the presence of downloaded dependencies using the ls command.
You can then install those rpm packages using the rpm command.
rpm -ivh *.rpm
Generally, the best and easiest way of installing packages is by using the yum install package-name or dnf install package-name commands. If you prefer downloading a package first and installing it later, ensure you download the dependencies as well using the --resolve flag and install all of them simultaneously to avoid getting dependencies errors.