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.
ls
You can then install those rpm packages using the rpm command.
For example:
rpm -ivh *.rpm
Conclusion
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.
I wonder why the manpage in the latest Fedora Workstation (release 38) left out the ‘download’ command, leading me to seek pages helping me with –downloadonly and –downloaddir=’…’. They didn’t mention a download option either.
An oversight by the dnf authors? I think not. Having mounted the live image and finding (after several mounts to get at the actual live files) there are no rpms, it was a copy of the live image saying ‘oh yeah, and this RPM is here too’. I can accept that, but I cannot accept the lack of accurate, truthful and complete documentation.
Meanwhile, This is not the place to scream about why more(1) has been altered from it’s native form. I was teethed on 4.2bsd and know more(1) exits when it hits EOF. WHY ARE THEY MUCKING WITH IT! If you don’t like more(1) – Use less(1)! Make an alias but don’t screw around with the defaults of an existing command!!! Now I need an alias for what was the norm, make more(1) exit when it hits EOF. Next I know cd(1) will be asking if I really want to alter my current working directory folder. ARRRRRGGGGGHHHH!
not an lol
It’s possible that they were overlooked or omitted during documentation.