≡ Menu

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

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: centos.mirrors.tds.net
 * updates: mirror.myriadnetwork.com
 * addons: mirrors.gigenet.com
 * extras: holmes.umflint.edu
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
=============================================================================
Installing:
 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
Complete!

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: centos.mirrors.mypsh.com
 * updates: mirror.steadfast.net
 * addons: mirrors.gigenet.com
 * extras: holmes.umflint.edu
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
=============================================================================
Installing:
 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

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 39 comments… add one }

  • Grrruk October 6, 2008, 8:40 am

    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…

    • Nick Webb November 21, 2011, 1:51 am

      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

  • nixCraft October 6, 2008, 1:14 pm

    Grrruk,

    Noop, the only way to get it by visiting centos http / ftp mirrors.

  • LAMP setup: Beginning | www.redips.net December 5, 2008, 12:54 pm

    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!

  • ashu January 17, 2009, 12:34 pm

    Jai Hind

    Thanks vivek for this very cool and useful trick

  • Arun Kumar February 26, 2009, 5:34 pm

    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?

  • keLz March 7, 2009, 8:34 am

    This doesnt work if you already have the package.
    Is there a way around this?

    • Golda October 29, 2010, 12:54 pm

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

      • asdf@asdf.tld April 19, 2011, 1:31 pm

        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.

        thanks!!!!!

        • asdf@asdf.tld April 19, 2011, 1:36 pm

          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

      • John March 11, 2013, 4:08 pm

        Thanks Golda,

        Your tip saved me a huge headache just now :)

  • venugopal March 12, 2009, 7:42 am

    i want to install qmail in rhel5

  • Devin March 19, 2009, 10:37 pm

    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

  • ashwani July 8, 2009, 1:55 pm

    but this doesnt work on yum groupinstall it gives error

  • sjoshi October 8, 2009, 7:04 pm

    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..
    Thanks

  • dan October 21, 2009, 2:51 pm

    This works great – thanks for the tip !

  • milek November 4, 2009, 9:46 pm

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

  • James February 17, 2010, 2:21 pm

    great milek! thats just what i was looking for, thanks!

  • nixCraft March 9, 2010, 5:54 am

    @ milek,

    Thanks for the heads up. The faq has been updated.

  • Hari April 21, 2010, 2:28 am

    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.

  • poboy December 7, 2010, 9:06 am

    thanks very much!

  • Raju Hasan May 25, 2011, 12:44 am

    How do i download mediaplayer for Redhat 5 with windows moode?

  • Pioup August 16, 2011, 7:45 pm

    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?

  • Jayaram Prasad August 20, 2011, 5:59 pm

    Yes,

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

    yum install yum-downloadonly

    yumdownloader gcc

    Jai.

  • Jake August 24, 2011, 4:53 pm

    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?

  • Sandy September 21, 2011, 1:27 pm

    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.

    Thanks,
    Sandy

  • jayaram Prasad September 22, 2011, 3:22 am

    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…

  • Sandy September 25, 2011, 4:27 pm

    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.

    Thanks,
    Sandy

  • Sandy September 25, 2011, 4:40 pm

    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.

  • Sandy October 20, 2011, 12:48 pm

    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,

    [rhel-local]
    name=rhel-local $releaseserver $basearch – rhel-local
    baseurl=file:///root/RPM_Updates/downloads
    enabled=1
    gpgcheck=0

    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 :)

    • Chuck Ho April 2, 2013, 8:15 pm

      Thanx Sandy!! Everything work exactly like the way you posted!

  • Glauco Furlaneto November 3, 2011, 9:48 am

    Excelent article, Vivek Gite.
    []’s

  • Rodger November 29, 2011, 7:46 pm

    Hello,

    My system:
    Oracle Redhat 5.5

    cat /proc/version
    Linux version 2.6.18-194.el5xen (mockbuild@ca-build10.us.oracle.com) (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!

  • Martin Allert March 28, 2012, 5:17 pm

    Use the yumdownloader, Luke! :) You need to install the yum-tools first….

  • badal jain April 13, 2012, 6:24 am

    how can i copy the packages of the media on rhel -5..
    please give complete steps.
    thanxs.

  • alireza seighalani December 15, 2012, 9:41 pm

    youre article is amazing. thanks man ;)

  • joe February 1, 2013, 1:56 pm

    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

  • brian April 10, 2013, 4:12 pm

    I hate to burst your bubble, but according to testout.com, 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.

  • Lefeuvre October 24, 2014, 2:34 pm

    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
    Nicole

Leave a Comment