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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 36 comments… read them below or add one }
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…
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
Grrruk,
Noop, the only way to get it by visiting centos http / ftp mirrors.
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!
Jai Hind
Thanks vivek for this very cool and useful trick
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?
This doesnt work if you already have the package.
Is there a way around this?
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
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!!!!!
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
Thanks Golda,
Your tip saved me a huge headache just now :)
i want to install qmail in rhel5
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
but this doesnt work on yum groupinstall it gives error
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
This works great – thanks for the tip !
Or just use:
yumdownloader [package]to download file in current dir
yumdownloader is part of yum-utils package:
yum install yum-utils
great milek! thats just what i was looking for, thanks!
@ milek,
Thanks for the heads up. The faq has been updated.
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.
thanks very much!
How do i download mediaplayer for Redhat 5 with windows moode?
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?
Yes,
Its great tool….I did the following steps to download CPP rpms
yum install yum-downloadonly
yumdownloader gcc
Jai.
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
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…
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
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.
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 :)
Thanx Sandy!! Everything work exactly like the way you posted!
Excelent article, Vivek Gite.
[]‘s
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!
Use the yumdownloader, Luke! :) You need to install the yum-tools first….
how can i copy the packages of the media on rhel -5..
please give complete steps.
thanxs.
youre article is amazing. thanks man ;)
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