Download Packages Without Installing on Linux

Today, we’ll take a look at how we can use package managers to download only rpm packages without installing them with all dependencies on Linux.

Yum and Dnf package managers are used in RedHat distributions namely RedHat, CentOS and Fedora mostly for installation, reinstallation, update, upgrade and removal of rpm packages.

Note: Kindly note that yum-utils package has been deprecated in Centos & RHEL 7

There are two ways of downloading packages without installing them

1) yum-downloadonly utility
2) using yumdownloader
3) using dnf-download

Installing yum-downloadonly tool (CentOS & RHEL 6.8)

Let's first install the downloadonly utility with the command below.

yum install yum-plugin-downloadonly

Downloading a package using yum-downloadonly

Now that we have downloaded the utility tool, let's see how we can download a web server package (httpd)

yum install –-downloadonly httpd

Sample Output

[[email protected] ~]# yum install --downloadonly httpd
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.linode.com
 * extras: mirrors.linode.com
 * updates: mirrors.linode.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-60.el6.centos.6 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-60.el6.centos.6 for package: htt                                                                                        pd-2.2.15-60.el6.centos.6.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-60.el6.centos                                                                                        .6.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-60.el6.cent                                                                                        os.6.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-                                                                                        60.el6.centos.6.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-60.e                                                                                        l6.centos.6.x86_64

NOTE: By default, the package is downloaded to /var/cache/yum directory. To specify an alternative path append the --downloaddir=/path/ flag e.g

yum -y install --downloadonly --downloaddir=/opt samba

The above command stores the samba package in the /opt directory.

Installing yumdownloader (CentOS & RHEL 7)

Install the EPEL repo first. Note that yum-utils is deprecated in Centos & RHEL 7

yum install epel-release

Downloading a package using yumdownloader

To download a package, run the command as shown below. The example shows the download of an openssh server.

yumdownloader package-name

rpm-yumdownloader

NOTE:
The package is downloaded to the current working directory. You can specify an alternative directory by appending   -- destdir flag.

To download the package alongside the dependencies, append the  --resolve flag.

rpm-yumdownloader

Verifying the presence of dependencies

ls

rpm saved-yumdownloader dependencies

Downloading a package using dnf (Fedora 22 and later versions)

On Fedora 22 and later, yum is deprecated and in its place is the dnf package manager. To download a package using dnf, run the command as shown. The example below illustrates download of samba package.

dnf download package-name

dnf-samba rpm download

Downloading with dependencies

To download the dependencies, append the --resolve flag

dnf download samba --resolve

dnf-samba dependencies rpm

Verify existence or download of dependencies

Check the presence of downloaded dependencies using the ls command.

ls

dnf-download verify rpm dependencies

Read Also:

Generally, the best and easiest way of installing packages is by using the yum install package-name 0r 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.

Jamie Arthur 9:22 am

About Jamie Arthur

Hey, I'm James, a passionate Linux Systems administrator, and a tech enthusiast. I derive immense gratification in conducting research on Linux systems and keeping myself up to date with the latest in the technology world.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.