How To Download a RPM Package Using yum Command Without Installing On Linux

last updated in Categories , , , ,

I would like to only download the packages via yum and not install/update them. How do I download a RPM package using yum command under CentOS Enterprise Linux server 5.x or RHEL 5.x systems?


You need to install plugin called yum-downloadonly. This plugin adds a –downloadonly flag to yum so that yum will only download the packages and not install/update them. Following options supported by this plugin:

[a] –downloadonly : don’t update, just download a rpm file
[b] –downloaddir=/path/to/dir : specifies an alternate directory to store packages such as /tmp

Please note following instructions are only tested on CentOS server but should work with RHN and RHEL without any problem.

How do I install yum-downloadonly plugin?

Type the following command to install plugin, enter:
# yum install yum-downloadonly
Sample output:

Loading "fastestmirror" plugin
Loading "security" plugin
Loading mirror speeds from cached hostfile
 * base:
 * updates:
 * addons:
 * extras:
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package yum-downloadonly.noarch 0:1.1.10-9.el5.centos set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

 Package                 Arch       Version          Repository        Size 
 yum-downloadonly        noarch     1.1.10-9.el5.centos  base              9.0 k

Transaction Summary
Install      1 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         

Total download size: 9.0 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): yum-downloadonly-1 100% |=========================| 9.0 kB    00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: yum-downloadonly             ######################### [1/1] 

Installed: yum-downloadonly.noarch 0:1.1.10-9.el5.centos

How do I download a RPM package only from RHN or CentOS mirror, without installing it?

Download httpd package but don’t install/update, enter:
# yum update httpd -y --downloadonly
By default package will by downloaded and stored in /var/cache/yum/ directory. But, you can specifies an alternate directory to store packages such as /opt, enter:
# yum update httpd -y --downloadonly --downloaddir=/opt
Sample output:

yum install httpd -y --downloadonly 
Loading "downloadonly" plugin
Loading "fastestmirror" plugin
Loading "security" plugin
Loading mirror speeds from cached hostfile
 * base:
 * updates:
 * addons:
 * extras:
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package httpd.i386 0:2.2.3-11.el5_1.centos.3 set to be updated
filelists.xml.gz          100% |=========================| 2.8 MB    00:03     
filelists.xml.gz          100% |=========================| 681 kB    00:11     
filelists.xml.gz          100% |=========================| 122 kB    00:00     
filelists.xml.gz          100% |=========================|  150 B    00:00     
--> Finished Dependency Resolution

Dependencies Resolved

 Package                 Arch       Version          Repository        Size 
 httpd                   i386       2.2.3-11.el5_1.centos.3  base              1.1 M

Transaction Summary
Install      1 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         

Total download size: 1.1 M
Downloading Packages:
(1/1): httpd-2.2.3-11.el5 100% |=========================| 1.1 MB    00:01     

exiting because --downloadonly specified 

To see downloaded file, enter:
# ls -l /opt/*.rpm
Sample output:

-rw-r--r-- 1 root root 1116426 Jan 17 03:36 /opt/httpd-2.2.3-11.el5_1.centos.3.i386.rpm
-rw-r--r-- 1 root root   83452 Oct  2  2007 /opt/lighttpd-fastcgi-1.4.18-1.el5.rf.i386.rpm
-rw-r--r-- 1 root root  635045 Oct 20  2007 /opt/psad-2.1-1.i386.rpm

Method # 2: yum-utils.noarch Package

yum-utils is a collection of utilities and examples for the yum package manager. It includes utilities by different authors that make yum easier and more powerful to use. These tools include: debuginfo-install, package-cleanup, repoclosure, repodiff, repo-graph, repomanage, repoquery, repo-rss, reposync, repotrack, verifytree, yum-builddep, yum-complete-transaction, yumdownloader, yum-debug-dump and yum-groups-manager.
# yum -y install yum-utils.noarch
Now use the yumdownloader command which is a program for downloading RPMs from Yum repositories. Type the following command to download httpd rpm file:
# yumdownloader httpd
Sample outputs:

Loaded plugins: rhnplugin
httpd-2.2.3-31.el5_4.2.x86_64.rpm                        | 1.2 MB     00:00 

How Do I Extract Downloaded RPM File?

Type the command as follows:
# rpm2cpio httpd-2.2.3-31.el5_4.2.x86_64.rpm | cpio -idmv


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

39 comment

  1. Damn… it doesn’t work on CentOS 4.6. Is there way to do this on 4.x branch? Upgrading OS is not an option and yum install yum-downloadonly does not work…

    1. I just did this today on CentOS 4.x… you can’t really do the same thing, but you can download all the needed updates to a directory, then install at your leisure with ‘rpm -Uvh *.rpm’. Here is the command I used:

      yum check-update | egrep ‘(base|updates)’ | awk ‘{ print $1 }’ | xargs -n 10 yumdownloader

  2. That is what I’m looking for. I have FC10 desktop at my work place, and another FC10 at my home. This way I could spare my home bandwidth …
    Thank you!

  3. I have some packages which are installed using yum command. Now, I installed downloadonly plug-in. How can I download these packages without uninstalling the installed packages?

    1. You can do
      yum reinstall [package] –downloadonly
      and it will stop during the reinstall and leave the package in a subdirectory of
      this worked better for me than using –installroot

      1. reinstall <<< omg this is brilliant.

        so obvious so simple. there are thousands of posts on the internet that say you can't force install using yum if you already have the package installed, yet your needled in the haystack post, proves them all wrong.

        this worked for me. i accidently erased 1 file from a package. i just need to put that one file back, so i used the reinstall option, and the download only option, and then extracted the rpm package, and placed that one single file back. brilliant.


        1. p.s.

          a quick followup, I wanted to download a copy of the package rpm that I already have installed, so I did a

          yum reinstall –downloadonly –downloaddir=/home/bob package-1.3-7

          but if you want to download a copy of a package older then you have then

          yum downgrade –downloadonly –downloaddir=/home/bob package-1.3-1

  4. use the –installroot option for yum to download already-installed packages.

    It’ll download all the package’s dependencies to that location, but at least you’ll have the rpm you wanted.

    so do:
    yum install –downloadonly –downloaddir=/tmp/ –installroot=/tmp

    *edit* posted with wrong e-mail

  5. So, after it has been downloaded, I will try to take that package to another machine without internet connect and install from the downloaded package. What command would I run to install it from the downloaded package and not using internet connection?
    If yum can’t do it, could anybody provide a another command or so..

  6. Or just use:
    yumdownloader [package]
    to download file in current dir
    yumdownloader is part of yum-utils package:
    yum install yum-utils

  7. Thank you so much for this guide, it helped me to download R-core and about 15 of its missing dependencies that I needed in a single shot for a later install.

  8. And how I can download “yum-downloadonly-plugin” without install it ????
    This is the big lack I can’t stand on “Yum” distros! How I can do my scripts post-installation with a such lack?
    This package is not heavy, so why isn’t not installed in standard?

  9. Yes,

    Its great tool….I did the following steps to download CPP rpms

    yum install yum-downloadonly

    yumdownloader gcc


  10. New to CENTOS & Yum, looking for the best way to download Splunk to our brand new server setup …. yum install is the command, but how do I get the Splunk download package to where I can install it?

  11. We have RHN subsciption and successfully downloaded updates available to the specified destination directory.

    I copied these downloaded files to RHEL5.5 machine.(which can not be kept under network due to security reasons)
    Now, I need to do offline install/update of the downloaded packages on this machine.But failed to do this. Any suggestions ?
    I used “yum localupdate *” command to perform this operation.

    One strange fact is, yum localupdate command is resolving dependancies when connected to RHN. But, on a offline machine even though I have copied all dependant packages it is not resolving dependencies(For Ex., to update an already installed package it is unable to install a new package available in the same directory).

    Any help is appreciated.


  12. Then why cant you prepare a shellscript by including all the packages to be installed at once by giving the location too…
    I mean we could try like rpm -Uvh some-thing.rpm
    to install use just rpm -ivh some-thing.rpm
    make this like a shell script and install them…

  13. Jai Thanks for the reply.

    I understand that “rpm -Uvh” can update installed packages but it can not resolve dependencies on its own. Ok, let me put my question this way,
    why “yum localupdate * ” command on RHN connected machine is resolving dependencies on its own ? and why not the same command on an offline machine can not resolve all dependencies though all dependent packages are in the same local directory ?
    My intention here is, do not resolve any dependency issues manually on an offline machine. localupdate by name it should behave similar on a RHN connected machine as well as on an offline machine.

    Correct me if I am missing anything during packaging and extracting on an offline machine.
    I downloaded all updates using ” yum update -y –downloadonly –downloaddir=/tmp ” and copied all these files to offline machine and ran “yum localupdate * ” command.


  14. One more quick point, I am allowed to use/setup any yum repositories to achieve these automated updates of RPMs installed on a offline machine.

  15. Yeah.. I figured it out myself. I followed the below sequense to install downloaded RPM updates on a offline machine.

    First downloaded RPM updates on a RHN registered machine in the following way,
    1) yum install yum-downloadonly // installed yum download only plugin
    //Downloaded availbale RPM updates to the /root/RPM_Updates/downloads directory
    2) yum update -y –downloadonly –downloaddir=/root/RPM_Updates/downloads
    3) Packaged these downloads into a tar file and transferred them to the offline machine.

    On a offline machine, I created a local repository of downloaded RPMs and installed them using yum update command. in the following way,
    1) Untar’ed RPM updates to the “/root/RPM_Updates/downloads” directory
    2) Created rhel_local.repo file with the following content and copied it into /etc/yum.repos.d directory,

    name=rhel-local $releaseserver $basearch – rhel-local

    3) Installed createrepo rpm using Yum localinstall command.
    yum localinstall createrepo-0.4.11-3.el5.noarch.rpm # Before executing this command, This RPM was downloaded from the RHN connected machine and copied to this offline machine.
    4) createrepo /root/RPM_Updates/downloads # Created local repository with this command.
    5) Yum update -y # Hurrah I succefully installed RPM updates now from the local repository with out any need of registering the machine with RHN. Ofcourse, I downloded these updated RPMs from the official RHN registered machine :)

  16. Hello,

    My system:
    Oracle Redhat 5.5

    cat /proc/version
    Linux version 2.6.18-194.el5xen ( (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Mon Mar 29 22:22:00 EDT 2010

    I’m trying to get yum to work.
    I tried your command.

    yum -v install yum-downloadonly

    Loading “security” plugin
    Config time: 0.040
    Yum Version: 3.2.22
    Setting up Package Sacks
    rpmdb time: 0.000
    Setting up Install Process
    Setting up Package Sacks
    Checking for virtual provide or file-provide for yum-downloadonly
    Searching pkgSack for dep: yum-downloadonly
    Setting up Package Sacks
    No package yum-downloadonly available.
    Setting up Package Sacks
    Nothing to do

    Is there some kind of configuration I need to do first?

    If so, what is a link explaining this?

    Thanks a lot!

  17. Hi,

    How do you also get the dependencies as well?

    I went from rhel 5.4 to 5.6 and now the yum errors out.

    Thanks, Joe

  18. I hate to burst your bubble, but according to, the answer was yumdownloader. they’re a company that prepares you for your A+ certification, and I would double-check the answer you’re saying it is.

  19. Hello

    We would like to xpdf on LINUX RH 6. The .rpm file is only 1.7MB and since we do not have access to Internet on our server when we execute the .rpm file it does not download the dependencies.

    How can i download the dependencies and the entire package when i don’t have access to Internet?

    Shall i use YUM?

    Best regards

    Still, have a question? Get help on our forum!